version 1.3, 2016/09/02 21:48:03 |
version 1.4, 2016/09/02 21:52:12 |
|
|
size_t len = 0; |
size_t len = 0; |
int state = 0; |
int state = 0; |
ssize_t n; |
ssize_t n; |
uint8_t *buf = xmalloc(sz); |
uint8_t *buf; |
|
|
if (!buf) |
buf = xmalloc(sz); |
exit(1); |
|
|
|
while (1) { |
while (1) { |
if (len == sz) { |
if (len == sz) { |
|
|
if (len < 10) |
if (len < 10) |
continue; |
continue; |
h->flg = buf[3]; |
h->flg = buf[3]; |
h->mtime = buf[4] | (buf[5] << 8U) | (buf[6] << 16U) | |
h->mtime = buf[4] | (buf[5] << 8U) | (buf[6] << 16U) | |
(buf[7] << 24U); |
(buf[7] << 24U); |
h->xflg = buf[8]; |
h->xflg = buf[8]; |
h->os = buf[9]; |
h->os = buf[9]; |
|
|
} |
} |
} |
} |
|
|
static void |
static void |
copy_blocks(int fdout, int fdin, const char *sha, const char *endsha, |
copy_blocks(int fdout, int fdin, const char *sha, const char *endsha, |
size_t bufsize, uint8_t *bufend) |
size_t bufsize, uint8_t *bufend) |
{ |
{ |
uint8_t *buffer = xmalloc(bufsize); |
uint8_t *buffer; |
|
uint8_t *residual; |
uint8_t *residual = (uint8_t *)endsha+1; |
|
uint8_t output[SHA256_DIGEST_STRING_LENGTH]; |
uint8_t output[SHA256_DIGEST_STRING_LENGTH]; |
|
|
|
buffer = xmalloc(bufsize); |
|
residual = (uint8_t *)endsha + 1; |
|
|
while (1) { |
while (1) { |
/* get the next block */ |
/* get the next block */ |
size_t n = 0; |
size_t n = 0; |
|
|
residual += len; |
residual += len; |
n = len; |
n = len; |
} |
} |
} |
} |
/* if we're not done yet, try to obtain more until EOF */ |
/* if we're not done yet, try to obtain more until EOF */ |
while (n != bufsize) { |
while (n != bufsize) { |
ssize_t more = read(fdin, buffer+n, bufsize-n); |
ssize_t more = read(fdin, buffer+n, bufsize-n); |
|
|
writeall(fdout, buffer, n, "stdout"); |
writeall(fdout, buffer, n, "stdout"); |
if (n != bufsize) |
if (n != bufsize) |
break; |
break; |
} |
} |
free(buffer); |
free(buffer); |
} |
} |
|
|
|
|
char *p; |
char *p; |
uint8_t *bufend; |
uint8_t *bufend; |
int fdin, fdout; |
int fdin, fdout; |
|
|
/* by default, verification will love pipes */ |
/* by default, verification will love pipes */ |
if (!sigfile) |
if (!sigfile) |
sigfile = "-"; |
sigfile = "-"; |
|
|
errx(1, "%s is an unsigned archive", sigfile); |
errx(1, "%s is an unsigned archive", sigfile); |
fake[8] = h.xflg; |
fake[8] = h.xflg; |
|
|
p = verifyzdata(h.comment, h.endcomment-h.comment, sigfile, |
p = verifyzdata(h.comment, h.endcomment-h.comment, sigfile, |
pubkeyfile, keytype); |
pubkeyfile, keytype); |
|
|
bufsize = MYBUFSIZE; |
bufsize = MYBUFSIZE; |
|
|
if (lseek(fdin, h.headerlength, SEEK_SET) == -1) |
if (lseek(fdin, h.headerlength, SEEK_SET) == -1) |
err(1, "seek in %s", msgfile); |
err(1, "seek in %s", msgfile); |
|
|
space = (sb.st_size / MYBUFSIZE) * SHA256_DIGEST_STRING_LENGTH + |
space = (sb.st_size / MYBUFSIZE) * SHA256_DIGEST_STRING_LENGTH + |
80; /* long enough for blocksize=.... */ |
80; /* long enough for blocksize=.... */ |
|
|
msg = xmalloc(space); |
msg = xmalloc(space); |
|
|
free(buffer); |
free(buffer); |
close(fdout); |
close(fdout); |
} |
} |
|
|
#endif |
#endif |