From: Alex Elder Date: Fri, 18 Feb 2011 21:21:01 +0000 (+0000) Subject: xfsprogs: metadump: ensure dup table always has entry for obfuscated name X-Git-Tag: v3.1.5~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2e10856e0b5142e9b6d587af221c4d679830232;p=thirdparty%2Fxfsprogs-dev.git xfsprogs: metadump: ensure dup table always has entry for obfuscated name We need to ensure the nametable has a copy of all the names in a directory (or attribute fork) in order to avoid creating duplicate entries when obfuscating names. Currently there is an (unlikely) case where the name is passed back without such an entry being created. Reorder things so that won't happen. Signed-off-by: Alex Elder Reviewed-by: Dave Chinner --- diff --git a/db/metadump.c b/db/metadump.c index 9b72d6ce2..143fcba13 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -550,18 +550,22 @@ generate_obfuscated_name( } } while (dup); - memcpy(name, newname, namelen); + /* Create an entry for the name in the name table */ p = malloc(sizeof(name_ent_t) + namelen); if (p == NULL) return; - p->next = nametable[hash % NAME_TABLE_SIZE]; - p->hash = hash; p->namelen = namelen; - memcpy(p->name, name, namelen); + memcpy(p->name, newname, namelen); + p->hash = hash; + p->next = nametable[hash % NAME_TABLE_SIZE]; nametable[hash % NAME_TABLE_SIZE] = p; + + /* Update the caller's copy with the obfuscated name */ + + memcpy(name, newname, namelen); } static void