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

Diff for /src/usr.bin/ssh/authfile.c between version 1.138 and 1.139

version 1.138, 2020/04/08 00:09:24 version 1.139, 2020/04/08 00:10:37
Line 189 
Line 189 
         return r;          return r;
 }  }
   
   /* Load a pubkey from the unencrypted envelope of a new-format private key */
 static int  static int
   sshkey_load_pubkey_from_private(const char *filename, struct sshkey **pubkeyp)
   {
           struct sshbuf *buffer = NULL;
           struct sshkey *pubkey = NULL;
           int r, fd;
   
           if (pubkeyp != NULL)
                   *pubkeyp = NULL;
   
           if ((fd = open(filename, O_RDONLY)) == -1)
                   return SSH_ERR_SYSTEM_ERROR;
           if ((r = sshbuf_load_fd(fd, &buffer)) != 0 ||
               (r = sshkey_parse_pubkey_from_private_fileblob_type(buffer,
               KEY_UNSPEC, &pubkey)) != 0)
                   goto out;
           if ((r = sshkey_set_filename(pubkey, filename)) != 0)
                   goto out;
           /* success */
           if (pubkeyp != NULL) {
                   *pubkeyp = pubkey;
                   pubkey = NULL;
           }
           r = 0;
    out:
           close(fd);
           sshbuf_free(buffer);
           sshkey_free(pubkey);
           return r;
   }
   
   static int
 sshkey_try_load_public(struct sshkey **kp, const char *filename,  sshkey_try_load_public(struct sshkey **kp, const char *filename,
     char **commentp)      char **commentp)
 {  {
Line 265 
Line 297 
         if (asprintf(&pubfile, "%s.pub", filename) == -1)          if (asprintf(&pubfile, "%s.pub", filename) == -1)
                 return SSH_ERR_ALLOC_FAIL;                  return SSH_ERR_ALLOC_FAIL;
         if ((r = sshkey_try_load_public(keyp, pubfile, commentp)) == 0)          if ((r = sshkey_try_load_public(keyp, pubfile, commentp)) == 0)
                   goto out;
   
           /* finally, try to extract public key from private key file */
           if ((r = sshkey_load_pubkey_from_private(filename, keyp)) == 0)
                 goto out;                  goto out;
   
  out:   out:

Legend:
Removed from v.1.138  
changed lines
  Added in v.1.139