xfs
[Top] [All Lists]

[PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfus

To: xfs@xxxxxxxxxxx
Subject: [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names
From: Alex Elder <aelder@xxxxxxx>
Date: Fri, 18 Feb 2011 15:21:02 -0600
User-agent: Heirloom mailx 12.5 7/5/10
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@xxxxxxx>

No significant changes in this version from the last version posted.

---
 db/metadump.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -412,12 +412,11 @@ nametable_add(xfs_dahash_t hash, int nam
 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)];
 }
 
 /*

<Prev in Thread] Current Thread [Next in Thread>