public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <aelder@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/6] xfsprogs: do slightly less obfuscation in the file name
Date: Wed, 06 Oct 2010 13:49:04 -0500	[thread overview]
Message-ID: <1286390944.1951.364.camel@doink> (raw)

When the last five characters in an obfuscated filename are
generated, one of them has a randomized top nibble.  This is a
fairly copmlete way of doing this.  But the lower nibble is already
effectively a random character (taken from four bits of a the hash
value) so we don't lose much by simply assuming the the top bits are
always zero.  This simplifies the generation of two of the final
five characters, and makes them all get done in a consistent way.
Add the use of a mask in the one case it wasn't used to be even more
consistent.

Signed-off-by: Alex Elder <aelder@sgi.com>

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

Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -464,8 +464,7 @@ generate_obfuscated_name(
 			 */
 			newhash = rol32(newhash, 3) ^ hash;
 
-			newp[namelen - 5] = (newhash >> 28) |
-					(random_filename_char() & 0xf0);
+			newp[namelen - 5] = (newhash >> 28) & 0x7f;
 			if (is_invalid_char(newp[namelen - 5]))
 				continue;
 			newp[namelen - 4] = (newhash >> 21) & 0x7f;
@@ -477,8 +476,7 @@ generate_obfuscated_name(
 			newp[namelen - 2] = (newhash >> 7) & 0x7f;
 			if (is_invalid_char(newp[namelen - 2]))
 				continue;
-			newp[namelen - 1] = ((newhash >> 0) ^
-					(newp[namelen - 5] >> 4)) & 0x7f;
+			newp[namelen - 1] = (newhash >> 0) & 0x7f;
 			if (is_invalid_char(newp[namelen - 1]))
 				continue;
 			break;


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

                 reply	other threads:[~2010-10-06 18:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1286390944.1951.364.camel@doink \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox