From: Dave Chinner <david@fromorbit.com>
To: Alex Elder <aelder@sgi.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names
Date: Thu, 24 Feb 2011 19:45:45 +1100 [thread overview]
Message-ID: <20110224084545.GC3166@dastard> (raw)
In-Reply-To: <201102182121.p1ILL2Ti029193@stout.americas.sgi.com>
On Fri, Feb 18, 2011 at 03:21:02PM -0600, Alex Elder wrote:
> 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>
>
> 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)];
> }
Why not just:
do {
c = random() % 127 + 1;
} while (!isalnum(c));
return c;
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-02-24 8:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-18 21:21 [PATCH v3, 15/16] xfsprogs: metadump: use printable characters for obfuscated names Alex Elder
2011-02-24 8:45 ` Dave Chinner [this message]
2011-02-25 18:13 ` Alex Elder
2011-03-03 5:06 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110224084545.GC3166@dastard \
--to=david@fromorbit.com \
--cc=aelder@sgi.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.