[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 16, 2015 at 01:25:21PM -0700, tyson.w.smith@xxxxxxxxx wrote:
 > From: Tyson Smith <tyson.w.smith@xxxxxxxxx>
 > 
 > This will generate a path that will likely not exist but may
 > look somewhat valid or totally crazy depending on rand.

We kinda tried this before. It stressed the negative dentry code
a little (perhaps a little too much tbh), but never really found
anything interesting, and just caused trinity to crap garbage
filenames all over the tmp dir.

Not sure it's worth trying this again. If we do, we should
make it a lot less likely to happen, like 1 in a 100 or something.


 > +	switch(rand() % 5) {

Someone recently added a handy ONE_IN macro :)

 > +	case 0:
 > +		// single repeating random ASCII character
 > +		(void) memset(path, (rand() % 95) + 32, rand() % len);
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 1:
 > +		// random ASCII characters 32(space) -> 126(~)
 > +		for (i=0; i < len; i++)
 > +			path[i] = (char) ((rand() % 95) + 32);
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 2:
 > +		// random . or /
 > +		for (i=0; i < len; i++)
 > +			path[i] = RAND_BOOL() ? '.' : '/';
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 3:
 > +		// format strings
 > +		for (i=0; i < (len - 2); i+=2) {
 > +			path[i] = '%';
 > +			path[i+1] = fmts[rand() % 3];
 > +		}
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 4:
 > +		// junk
 > +		for (i=0; i < len; i++)
 > +			path[i] = (char) RAND_BYTE();
 > +		path[len-1] = '\0';
 > +		break;
 > +	}

This should probably just be a generate_rand_bytes() call,
with enhancements to that function if necessary.

	Dave
--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux