From: Alex Elder Date: Fri, 18 Feb 2011 21:21:02 +0000 (+0000) Subject: xfsprogs: metadump: use printable characters for obfuscated names X-Git-Tag: v3.1.5~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3a9916aaa8eeb76329df710a50bc97080e9265;p=thirdparty%2Fxfsprogs-dev.git xfsprogs: metadump: use printable characters for obfuscated names There is probably not much need for an extreme amount of randomness in the obfuscated names produced in metadumps. Limit the character set used for (most of) these names to printable characters rather than every permittable byte. The result makes metadumps a bit more natural to work with. I chose the set of all upper- and lower-case letters, digits, and the dash and underscore for the alphabet. It could easily be expanded to include others (or reduced for that matter). This change also avoids ever having to retry after picking an unusable character. Signed-off-by: Alex Elder Reviewed-by: Dave Chinner --- diff --git a/db/metadump.c b/db/metadump.c index 42f44a75c..491635277 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -408,12 +408,11 @@ nametable_add(xfs_dahash_t hash, int namelen, uchar_t *name) static inline uchar_t random_filename_char(void) { - uchar_t c; + static uchar_t filename_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789-_"; - do { - c = random() % 127 + 1; - } while (c == '/'); - return c; + return filename_alphabet[random() % (sizeof filename_alphabet - 1)]; } #define ORPHANAGE "lost+found"