[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.118 and 1.119

version 1.118, 2016/09/10 12:23:16 version 1.119, 2016/09/26 17:49:52
Line 361 
Line 361 
   
         secname = strstr(seckeyfile, ".sec");          secname = strstr(seckeyfile, ".sec");
         if (secname && strlen(secname) == 4) {          if (secname && strlen(secname) == 4) {
                   const char *keyname;
                   /* basename may or may not modify input */
                   if (!(keyname = strrchr(seckeyfile, '/')))
                           keyname = seckeyfile;
                 if ((nr = snprintf(sigcomment, sizeof(sigcomment), VERIFYWITH "%.*s.pub",                  if ((nr = snprintf(sigcomment, sizeof(sigcomment), VERIFYWITH "%.*s.pub",
                     (int)strlen(seckeyfile) - 4, seckeyfile)) == -1 || nr >= sizeof(sigcomment))                      (int)strlen(keyname) - 4, keyname)) == -1 || nr >= sizeof(sigcomment))
                         errx(1, "comment too long");                          errx(1, "comment too long");
         } else {          } else {
                 if ((nr = snprintf(sigcomment, sizeof(sigcomment), "signature from %s",                  if ((nr = snprintf(sigcomment, sizeof(sigcomment), "signature from %s",
Line 468 
Line 472 
 readpubkey(const char *pubkeyfile, struct pubkey *pubkey,  readpubkey(const char *pubkeyfile, struct pubkey *pubkey,
     const char *sigcomment, const char *keytype)      const char *sigcomment, const char *keytype)
 {  {
         const char *safepath = "/etc/signify/";          const char *safepath = "/etc/signify";
           char keypath[1024];
   
         if (!pubkeyfile) {          if (!pubkeyfile) {
                 pubkeyfile = strstr(sigcomment, VERIFYWITH);                  pubkeyfile = strstr(sigcomment, VERIFYWITH);
                 if (pubkeyfile) {                  if (pubkeyfile && strchr(pubkeyfile, '/') == NULL) {
                         pubkeyfile += strlen(VERIFYWITH);                          pubkeyfile += strlen(VERIFYWITH);
                         if (strncmp(pubkeyfile, safepath, strlen(safepath)) != 0 ||  
                             strstr(pubkeyfile, "/../") != NULL)  
                                 errx(1, "untrusted path %s", pubkeyfile);  
 #ifndef VERIFYONLY  #ifndef VERIFYONLY
                         if (keytype)                          if (keytype)
                                 check_keytype(pubkeyfile, keytype);                                  check_keytype(pubkeyfile, keytype);
 #endif  #endif
                           if (snprintf(keypath, sizeof(keypath), "%s/%s",
                               safepath, pubkeyfile) >= sizeof(keypath))
                                   errx(1, "name too long %s", pubkeyfile);
                 } else                  } else
                         usage("must specify pubkey");                          usage("must specify pubkey");
           } else {
                   if (strlcpy(keypath, pubkeyfile, sizeof(keypath)) >=
                       sizeof(keypath))
                           errx(1, "name too long %s", pubkeyfile);
         }          }
         readb64file(pubkeyfile, pubkey, sizeof(*pubkey), NULL);          readb64file(keypath, pubkey, sizeof(*pubkey), NULL);
 }  }
   
 static void  static void

Legend:
Removed from v.1.118  
changed lines
  Added in v.1.119