From 98e73203bf9df504cd45baab0bee63c6fe7a14df Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Tue, 12 Jan 2016 01:04:13 +0100 Subject: metaentry.c: Fix meta entry handling in case of xattr errors. getxattr() call can fail in mentry_create(), so NULL-initialize mentry->xattr_values[i] and update mentry->xattrs upon error, so there is no attempt in mentry_free() to free unitialized xattr_names[i] and xattr_values[i] pointers. Fixes #38. --- src/metaentry.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/metaentry.c b/src/metaentry.c index fdb7f71..25bb00f 100644 --- a/src/metaentry.c +++ b/src/metaentry.c @@ -266,11 +266,14 @@ mentry_create(const char *path) continue; mentry->xattr_names[i] = xstrdup(attr); + mentry->xattr_values[i] = NULL; + vsize = getxattr(path, attr, NULL, 0); if (vsize < 0) { msg(MSG_ERROR, "getxattr failed for %s: %s\n", path, strerror(errno)); free(list); + mentry->xattrs = i + 1; mentry_free(mentry); return NULL; } @@ -283,6 +286,7 @@ mentry_create(const char *path) msg(MSG_ERROR, "getxattr failed for %s: %s\n", path, strerror(errno)); free(list); + mentry->xattrs = i + 1; mentry_free(mentry); return NULL; } -- cgit v1.2.1