if(end == argv[1])
fatal(0, "invalid size");
if(!strcmp(end, "K"))
- size *= 1024;
+ size <<= 10;
else if(!strcmp(end, "M"))
- size *= 1024 * 1024;
+ size <<= 20;
else if(!strcmp(end, "G"))
- size *= 1024 * 1024 * 1024;
+ size <<= 30;
else if(*end)
fatal(0, "invalid size");
} else if(entireopt) {
// write/verify the target file
static long long execute(mode_type mode, bool entire, const char *show) {
- Arcfour rng((const char*)seed, seedlen);
+ Arcfour rng((const uint8_t *)seed, seedlen);
FILE *fp = fopen(path, mode == VERIFY ? "rb" : "wb");
if(!fp)
fatal(errno, "%s", path);
flushCache(fp);
if(mode == CREATE && entire)
setvbuf(fp, 0, _IONBF, 0);
- char generated[4096], input[4096];
+ uint8_t generated[4096], input[4096];
long long remain = size;
static const size_t rc4drop = 3072; // en.wikipedia.org/wiki/RC4#Security
assert(rc4drop <= sizeof(generated));
if(memcmp(generated, input, bytesRead)) {
for(size_t n = 0; n < bytesRead; ++n)
if(generated[n] != input[n])
- fatal(0, "%s corrupted at %lld/%lld bytes (expected %d got %d)",
+ fatal(0, "%s: corrupted at %lld/%lld bytes (expected %d got %d)",
path, size - remain + n, size,
(unsigned char)generated[n], (unsigned char)input[n]);
}