[BACK]Return to zsig.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / signify

Diff for /src/usr.bin/signify/zsig.c between version 1.3 and 1.4

version 1.3, 2016/09/02 21:48:03 version 1.4, 2016/09/02 21:52:12
Line 61 
Line 61 
         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) {
Line 89 
Line 88 
                         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];
Line 128 
Line 127 
         }          }
 }  }
   
 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;
Line 152 
Line 154 
                                 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);
Line 173 
Line 175 
                 writeall(fdout, buffer, n, "stdout");                  writeall(fdout, buffer, n, "stdout");
                 if (n != bufsize)                  if (n != bufsize)
                         break;                          break;
         }          }
         free(buffer);          free(buffer);
 }  }
   
Line 186 
Line 188 
         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 = "-";
Line 199 
Line 202 
                 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;
Line 241 
Line 244 
         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);
Line 289 
Line 292 
         free(buffer);          free(buffer);
         close(fdout);          close(fdout);
 }  }
   
 #endif  #endif

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4