]> wimlib.net Git - wimlib/commitdiff
xattr ADS fixes
authorEric Biggers <ebiggers3@gmail.com>
Tue, 28 Aug 2012 04:59:44 +0000 (23:59 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 28 Aug 2012 04:59:44 +0000 (23:59 -0500)
src/dentry.c
src/lookup_table.h
src/mount.c

index ac158e84d5f48f4ec712ecba1b22eee609c51aa7..6676377859041bdf495692a4442f4507a803f40f 100644 (file)
@@ -1309,7 +1309,7 @@ int verify_dentry(struct dentry *dentry, void *wim)
        for (unsigned i = 0; i <= dentry->num_ads; i++) {
                const u8 *hash;
                hash = dentry_stream_hash_unresolved(dentry, i);
-               if (dentry_stream_name_len(dentry, i) && !is_zero_hash(hash)) {
+               if (!dentry_stream_name_len(dentry, i) && !is_zero_hash(hash)) {
                        num_unnamed_streams++;
                        unnamed_stream_idx = i;
                }
index 8634c7f9686e0206760a7de185c02b3f49b69398..43494efeb8c3e24bd43e9537776a234b20b13024 100644 (file)
@@ -294,8 +294,8 @@ static inline const u8 *dentry_stream_hash_unresolved(const struct dentry *dentr
                return dentry->ads_entries[stream_idx - 1].hash;
 }
 
-static inline unsigned dentry_stream_name_len(const struct dentry *dentry,
-                                             unsigned stream_idx)
+static inline u16 dentry_stream_name_len(const struct dentry *dentry,
+                                        unsigned stream_idx)
 {
        wimlib_assert(stream_idx <= dentry->num_ads);
        if (stream_idx == 0)
index 6bdd0c459e183f6607c79f3444add204cedf130f..1510fbfb0c1b3f2429afb8e735ba44134623daad 100644 (file)
@@ -1009,7 +1009,7 @@ static int wimfs_getxattr(const char *path, const char *name, char *value,
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
 
-       if (memcmp(name, "user.", 5) != 0)
+       if (strlen(name) < 5 || memcmp(name, "user.", 5) != 0)
                return -ENOATTR;
        name += 5;
 
@@ -1414,7 +1414,7 @@ static int wimfs_removexattr(const char *path, const char *name)
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
 
-       if (memcmp(name, "user.", 5) != 0)
+       if (strlen(name) < 5 || memcmp(name, "user.", 5) != 0)
                return -ENOATTR;
        name += 5;
 
@@ -1531,6 +1531,10 @@ static int wimfs_setxattr(const char *path, const char *name,
        if (!(mount_flags & WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR))
                return -ENOTSUP;
 
+       if (strlen(name) < 5 || memcmp(name, "user.", 5) != 0)
+               return -ENOATTR;
+       name += 5;
+
        dentry = get_dentry(w, path);
        if (!dentry)
                return -ENOENT;
@@ -1564,6 +1568,7 @@ static int wimfs_setxattr(const char *path, const char *name,
                        FREE(lte);
                        return -ENOMEM;
                }
+               memcpy(value_copy, value, size);
                lte->resource_location            = RESOURCE_IN_ATTACHED_BUFFER;
                lte->attached_buffer              = value_copy;
                lte->resource_entry.original_size = size;