]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: metadump: use printable characters for obfuscated names
authorAlex Elder <aelder@sgi.com>
Fri, 18 Feb 2011 21:21:02 +0000 (21:21 +0000)
committerAlex Elder <aelder@sgi.com>
Tue, 8 Mar 2011 18:04:52 +0000 (12:04 -0600)
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 <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
db/metadump.c

index 42f44a75c95bab1e9488efb3c9fee6e9ebb45ed3..49163527724256ca64cac89b20c12a93b4f47696 100644 (file)
@@ -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"