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

Diff for /src/usr.bin/signify/signify.c between version 1.121 and 1.122

version 1.121, 2016/09/27 02:02:47 version 1.122, 2016/09/27 02:13:27
Line 449 
Line 449 
         free(dummybuf);          free(dummybuf);
 }  }
   
 #ifndef VERIFYONLY  
 static void  static void
 check_keytype(const char *pubkeyfile, const char *keytype)  check_keytype(const char *pubkeyfile, const char *keytype)
 {  {
         size_t len;          const char *p;
         char *cmp;          size_t typelen;
         int slen;  
   
         len = strlen(pubkeyfile);          if (!(p = strrchr(pubkeyfile, '-')))
         slen = asprintf(&cmp, "-%s.pub", keytype);                  goto bad;
         if (slen < 0)          p++;
                 err(1, "asprintf error");          typelen = strlen(keytype);
         if (len < slen)          if (strncmp(p, keytype, typelen) != 0)
                 errx(1, "too short");                  goto bad;
           if (strcmp(p + typelen, ".pub") != 0)
                   goto bad;
           return;
   
         if (strcmp(pubkeyfile + len - slen, cmp) != 0)  bad:
                 errx(1, "wrong keytype");          errx(1, "incorrect keytype: %s is not %s", pubkeyfile, keytype);
         free(cmp);  
 }  }
 #endif  
   
 static void  static void
 readpubkey(const char *pubkeyfile, struct pubkey *pubkey,  readpubkey(const char *pubkeyfile, struct pubkey *pubkey,
Line 481 
Line 480 
                 pubkeyfile = strstr(sigcomment, VERIFYWITH);                  pubkeyfile = strstr(sigcomment, VERIFYWITH);
                 if (pubkeyfile && strchr(pubkeyfile, '/') == NULL) {                  if (pubkeyfile && strchr(pubkeyfile, '/') == NULL) {
                         pubkeyfile += strlen(VERIFYWITH);                          pubkeyfile += strlen(VERIFYWITH);
 #ifndef VERIFYONLY  
                         if (keytype)                          if (keytype)
                                 check_keytype(pubkeyfile, keytype);                                  check_keytype(pubkeyfile, keytype);
 #endif  
                         if (snprintf(keypath, sizeof(keypath), "%s/%s",                          if (snprintf(keypath, sizeof(keypath), "%s/%s",
                             safepath, pubkeyfile) >= sizeof(keypath))                              safepath, pubkeyfile) >= sizeof(keypath))
                                 errx(1, "name too long %s", pubkeyfile);                                  errx(1, "name too long %s", pubkeyfile);

Legend:
Removed from v.1.121  
changed lines
  Added in v.1.122