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

Diff for /src/usr.bin/ssh/authfd.c between version 1.102 and 1.103

version 1.102, 2017/05/04 06:10:57 version 1.103, 2017/05/05 10:42:49
Line 225 
Line 225 
  * Fetch list of identities held by the agent.   * Fetch list of identities held by the agent.
  */   */
 int  int
 ssh_fetch_identitylist(int sock, int version, struct ssh_identitylist **idlp)  ssh_fetch_identitylist(int sock, struct ssh_identitylist **idlp)
 {  {
         u_char type, code1 = 0, code2 = 0;          u_char type;
         u_int32_t num, i;          u_int32_t num, i;
         struct sshbuf *msg;          struct sshbuf *msg;
         struct ssh_identitylist *idl = NULL;          struct ssh_identitylist *idl = NULL;
         int r;          int r;
   
         /* Determine request and expected response types */  
         switch (version) {  
         case 1:  
                 code1 = SSH_AGENTC_REQUEST_RSA_IDENTITIES;  
                 code2 = SSH_AGENT_RSA_IDENTITIES_ANSWER;  
                 break;  
         case 2:  
                 code1 = SSH2_AGENTC_REQUEST_IDENTITIES;  
                 code2 = SSH2_AGENT_IDENTITIES_ANSWER;  
                 break;  
         default:  
                 return SSH_ERR_INVALID_ARGUMENT;  
         }  
   
         /*          /*
          * Send a message to the agent requesting for a list of the           * Send a message to the agent requesting for a list of the
          * identities it can represent.           * identities it can represent.
          */           */
         if ((msg = sshbuf_new()) == NULL)          if ((msg = sshbuf_new()) == NULL)
                 return SSH_ERR_ALLOC_FAIL;                  return SSH_ERR_ALLOC_FAIL;
         if ((r = sshbuf_put_u8(msg, code1)) != 0)          if ((r = sshbuf_put_u8(msg, SSH2_AGENTC_REQUEST_IDENTITIES)) != 0)
                 goto out;                  goto out;
   
         if ((r = ssh_request_reply(sock, msg, msg)) != 0)          if ((r = ssh_request_reply(sock, msg, msg)) != 0)
Line 265 
Line 251 
         if (agent_failed(type)) {          if (agent_failed(type)) {
                 r = SSH_ERR_AGENT_FAILURE;                  r = SSH_ERR_AGENT_FAILURE;
                 goto out;                  goto out;
         } else if (type != code2) {          } else if (type != SSH2_AGENT_IDENTITIES_ANSWER) {
                 r = SSH_ERR_INVALID_FORMAT;                  r = SSH_ERR_INVALID_FORMAT;
                 goto out;                  goto out;
         }          }
Line 290 
Line 276 
                 goto out;                  goto out;
         }          }
         for (i = 0; i < num;) {          for (i = 0; i < num;) {
                 switch (version) {                  if ((r = deserialise_identity2(msg, &(idl->keys[i]),
                 case 1:                      &(idl->comments[i]))) != 0) {
                         break;                          if (r == SSH_ERR_KEY_TYPE_UNKNOWN) {
                 case 2:                                  /* Gracefully skip unknown key types */
                         if ((r = deserialise_identity2(msg,                                  num--;
                             &(idl->keys[i]), &(idl->comments[i]))) != 0) {                                  continue;
                                 if (r == SSH_ERR_KEY_TYPE_UNKNOWN) {                          } else
                                         /* Gracefully skip unknown key types */                                  goto out;
                                         num--;  
                                         continue;  
                                 } else  
                                         goto out;  
                         }  
                         break;  
                 }                  }
                 i++;                  i++;
         }          }

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.103