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

Diff for /src/usr.bin/ssh/ssh-keyscan.c between version 1.156 and 1.157

version 1.156, 2024/04/30 15:40:43 version 1.157, 2024/05/06 19:26:17
Line 96 
Line 96 
         u_char c_status;        /* State of connection on this file desc. */          u_char c_status;        /* State of connection on this file desc. */
 #define CS_UNUSED 0             /* File descriptor unused */  #define CS_UNUSED 0             /* File descriptor unused */
 #define CS_CON 1                /* Waiting to connect/read greeting */  #define CS_CON 1                /* Waiting to connect/read greeting */
 #define CS_SIZE 2               /* Waiting to read initial packet size */  
 #define CS_KEYS 3               /* Waiting to read public key packet */  
         int c_fd;               /* Quick lookup: c->c_fd == c - fdcon */          int c_fd;               /* Quick lookup: c->c_fd == c - fdcon */
         int c_plen;             /* Packet length field for ssh packet */  
         int c_len;              /* Total bytes which must be read. */  
         int c_off;              /* Length of data read so far. */  
         int c_keytype;          /* Only one of KT_* */          int c_keytype;          /* Only one of KT_* */
         sig_atomic_t c_done;    /* SSH2 done */          sig_atomic_t c_done;    /* SSH2 done */
         char *c_namebase;       /* Address to free for c_name and c_namelist */          char *c_namebase;       /* Address to free for c_name and c_namelist */
         char *c_name;           /* Hostname of connection for errors */          char *c_name;           /* Hostname of connection for errors */
         char *c_namelist;       /* Pointer to other possible addresses */          char *c_namelist;       /* Pointer to other possible addresses */
         char *c_output_name;    /* Hostname of connection for output */          char *c_output_name;    /* Hostname of connection for output */
         char *c_data;           /* Data read from this fd */  
         struct ssh *c_ssh;      /* SSH-connection */          struct ssh *c_ssh;      /* SSH-connection */
         struct timespec c_ts;   /* Time at which connection gets aborted */          struct timespec c_ts;   /* Time at which connection gets aborted */
         TAILQ_ENTRY(Connection) c_link; /* List of connections in timeout order. */          TAILQ_ENTRY(Connection) c_link; /* List of connections in timeout order. */
Line 397 
Line 391 
         fdcon[s].c_name = name;          fdcon[s].c_name = name;
         fdcon[s].c_namelist = namelist;          fdcon[s].c_namelist = namelist;
         fdcon[s].c_output_name = xstrdup(oname);          fdcon[s].c_output_name = xstrdup(oname);
         fdcon[s].c_data = (char *) &fdcon[s].c_plen;  
         fdcon[s].c_len = 4;  
         fdcon[s].c_off = 0;  
         fdcon[s].c_keytype = keytype;          fdcon[s].c_keytype = keytype;
         monotime_ts(&fdcon[s].c_ts);          monotime_ts(&fdcon[s].c_ts);
         fdcon[s].c_ts.tv_sec += timeout;          fdcon[s].c_ts.tv_sec += timeout;
Line 417 
Line 408 
                 fatal("confree: attempt to free bad fdno %d", s);                  fatal("confree: attempt to free bad fdno %d", s);
         free(fdcon[s].c_namebase);          free(fdcon[s].c_namebase);
         free(fdcon[s].c_output_name);          free(fdcon[s].c_output_name);
         if (fdcon[s].c_status == CS_KEYS)  
                 free(fdcon[s].c_data);  
         fdcon[s].c_status = CS_UNUSED;          fdcon[s].c_status = CS_UNUSED;
         fdcon[s].c_keytype = 0;          fdcon[s].c_keytype = 0;
         if (fdcon[s].c_ssh) {          if (fdcon[s].c_ssh) {
Line 433 
Line 422 
         ncon--;          ncon--;
 }  }
   
 static void  
 contouch(int s)  
 {  
         TAILQ_REMOVE(&tq, &fdcon[s], c_link);  
         monotime_ts(&fdcon[s].c_ts);  
         fdcon[s].c_ts.tv_sec += timeout;  
         TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link);  
 }  
   
 static int  static int
 conrecycle(int s)  conrecycle(int s)
 {  {
Line 546 
Line 526 
 conread(int s)  conread(int s)
 {  {
         con *c = &fdcon[s];          con *c = &fdcon[s];
         size_t n;  
   
         if (c->c_status == CS_CON) {          if (c->c_status != CS_CON)
                 congreet(s);                  fatal("conread: invalid status %d", c->c_status);
                 return;  
         }  
         n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off);  
         if (n == 0) {  
                 error("read (%s): %s", c->c_name, strerror(errno));  
                 confree(s);  
                 return;  
         }  
         c->c_off += n;  
   
         if (c->c_off == c->c_len)          congreet(s);
                 switch (c->c_status) {  
                 case CS_SIZE:  
                         c->c_plen = htonl(c->c_plen);  
                         c->c_len = c->c_plen + 8 - (c->c_plen & 7);  
                         c->c_off = 0;  
                         c->c_data = xmalloc(c->c_len);  
                         c->c_status = CS_KEYS;  
                         break;  
                 default:  
                         fatal("conread: invalid status %d", c->c_status);  
                         break;  
                 }  
   
         contouch(s);  
 }  }
   
 static void  static void

Legend:
Removed from v.1.156  
changed lines
  Added in v.1.157