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

Diff for /src/usr.bin/ssh/packet.c between version 1.102.2.2 and 1.103

version 1.102.2.2, 2004/03/04 18:18:16 version 1.103, 2003/04/01 10:10:23
Line 108 
Line 108 
 static int packet_compression = 0;  static int packet_compression = 0;
   
 /* default maximum packet size */  /* default maximum packet size */
 u_int max_packet_size = 32768;  int max_packet_size = 32768;
   
 /* Flag indicating whether this module has been initialized. */  /* Flag indicating whether this module has been initialized. */
 static int initialized = 0;  static int initialized = 0;
Line 165 
Line 165 
                 buffer_init(&incoming_packet);                  buffer_init(&incoming_packet);
                 TAILQ_INIT(&outgoing);                  TAILQ_INIT(&outgoing);
         }          }
           /* Kludge: arrange the close function to be called from fatal(). */
           fatal_add_cleanup((void (*) (void *)) packet_close, NULL);
 }  }
   
 /* Returns 1 if remote host is connected via socket, 0 if not. */  /* Returns 1 if remote host is connected via socket, 0 if not. */
Line 263 
Line 265 
         cipher_set_keyiv(cc, dat);          cipher_set_keyiv(cc, dat);
 }  }
 int  int
 packet_get_ssh1_cipher(void)  packet_get_ssh1_cipher()
 {  {
         return (cipher_get_number(receive_context.cipher));          return (cipher_get_number(receive_context.cipher));
 }  }
Line 628 
Line 630 
                         buffer_compress_init_recv();                          buffer_compress_init_recv();
                 comp->enabled = 1;                  comp->enabled = 1;
         }          }
         /*          *max_blocks = ((u_int64_t)1 << (enc->block_size*2));
          * The 2^(blocksize*2) limit is too expensive for 3DES,  
          * blowfish, etc, so enforce a 1GB limit for small blocksizes.  
          */  
         if (enc->block_size >= 16)  
                 *max_blocks = (u_int64_t)1 << (enc->block_size*2);  
         else  
                 *max_blocks = ((u_int64_t)1 << 30) / enc->block_size;  
         if (rekey_limit)          if (rekey_limit)
                 *max_blocks = MIN(*max_blocks, rekey_limit / enc->block_size);                  *max_blocks = MIN(*max_blocks, rekey_limit / enc->block_size);
 }  }
Line 744 
Line 739 
 #endif  #endif
         /* increment sequence number for outgoing packets */          /* increment sequence number for outgoing packets */
         if (++p_send.seqnr == 0)          if (++p_send.seqnr == 0)
                 logit("outgoing seqnr wraps around");                  log("outgoing seqnr wraps around");
         if (++p_send.packets == 0)          if (++p_send.packets == 0)
                 if (!(datafellows & SSH_BUG_NOREKEY))                  if (!(datafellows & SSH_BUG_NOREKEY))
                         fatal("XXX too many packets with same key");                          fatal("XXX too many packets with same key");
Line 862 
Line 857 
                 /* Read data from the socket. */                  /* Read data from the socket. */
                 len = read(connection_in, buf, sizeof(buf));                  len = read(connection_in, buf, sizeof(buf));
                 if (len == 0) {                  if (len == 0) {
                         logit("Connection closed by %.200s", get_remote_ipaddr());                          log("Connection closed by %.200s", get_remote_ipaddr());
                         cleanup_exit(255);                          fatal_cleanup();
                 }                  }
                 if (len < 0)                  if (len < 0)
                         fatal("Read from socket failed: %.100s", strerror(errno));                          fatal("Read from socket failed: %.100s", strerror(errno));
Line 1013 
Line 1008 
                 cp = buffer_ptr(&incoming_packet);                  cp = buffer_ptr(&incoming_packet);
                 packet_length = GET_32BIT(cp);                  packet_length = GET_32BIT(cp);
                 if (packet_length < 1 + 4 || packet_length > 256 * 1024) {                  if (packet_length < 1 + 4 || packet_length > 256 * 1024) {
 #ifdef PACKET_DEBUG  
                         buffer_dump(&incoming_packet);                          buffer_dump(&incoming_packet);
 #endif  
                         packet_disconnect("Bad packet length %u.", packet_length);                          packet_disconnect("Bad packet length %u.", packet_length);
                 }                  }
                 DBG(debug("input: packet len %u", packet_length+4));                  DBG(debug("input: packet len %u", packet_length+4));
Line 1057 
Line 1050 
         if (seqnr_p != NULL)          if (seqnr_p != NULL)
                 *seqnr_p = p_read.seqnr;                  *seqnr_p = p_read.seqnr;
         if (++p_read.seqnr == 0)          if (++p_read.seqnr == 0)
                 logit("incoming seqnr wraps around");                  log("incoming seqnr wraps around");
         if (++p_read.packets == 0)          if (++p_read.packets == 0)
                 if (!(datafellows & SSH_BUG_NOREKEY))                  if (!(datafellows & SSH_BUG_NOREKEY))
                         fatal("XXX too many packets with same key");                          fatal("XXX too many packets with same key");
Line 1126 
Line 1119 
                         case SSH2_MSG_DISCONNECT:                          case SSH2_MSG_DISCONNECT:
                                 reason = packet_get_int();                                  reason = packet_get_int();
                                 msg = packet_get_string(NULL);                                  msg = packet_get_string(NULL);
                                 logit("Received disconnect from %s: %u: %.400s",                                  log("Received disconnect from %s: %u: %.400s",
                                     get_remote_ipaddr(), reason, msg);                                      get_remote_ipaddr(), reason, msg);
                                 xfree(msg);                                  xfree(msg);
                                 cleanup_exit(255);                                  fatal_cleanup();
                                 break;                                  break;
                         case SSH2_MSG_UNIMPLEMENTED:                          case SSH2_MSG_UNIMPLEMENTED:
                                 seqnr = packet_get_int();                                  seqnr = packet_get_int();
Line 1152 
Line 1145 
                                 break;                                  break;
                         case SSH_MSG_DISCONNECT:                          case SSH_MSG_DISCONNECT:
                                 msg = packet_get_string(NULL);                                  msg = packet_get_string(NULL);
                                 logit("Received disconnect from %s: %.400s",                                  log("Received disconnect from %s: %.400s",
                                     get_remote_ipaddr(), msg);                                      get_remote_ipaddr(), msg);
                                 cleanup_exit(255);                                  fatal_cleanup();
                                 xfree(msg);                                  xfree(msg);
                                 break;                                  break;
                         default:                          default:
Line 1311 
Line 1304 
         va_end(args);          va_end(args);
   
         /* Display the error locally */          /* Display the error locally */
         logit("Disconnecting: %.100s", buf);          log("Disconnecting: %.100s", buf);
   
         /* Send the disconnect message to the other side, and wait for it to get sent. */          /* Send the disconnect message to the other side, and wait for it to get sent. */
         if (compat20) {          if (compat20) {
Line 1331 
Line 1324 
   
         /* Close the connection. */          /* Close the connection. */
         packet_close();          packet_close();
         cleanup_exit(255);  
           fatal_cleanup();
 }  }
   
 /* Checks if there is any buffered output, and tries to write some of the output. */  /* Checks if there is any buffered output, and tries to write some of the output. */
Line 1441 
Line 1435 
         return interactive_mode;          return interactive_mode;
 }  }
   
 u_int  int
 packet_set_maxsize(u_int s)  packet_set_maxsize(int s)
 {  {
         static int called = 0;          static int called = 0;
   
         if (called) {          if (called) {
                 logit("packet_set_maxsize: called twice: old %d new %d",                  log("packet_set_maxsize: called twice: old %d new %d",
                     max_packet_size, s);                      max_packet_size, s);
                 return -1;                  return -1;
         }          }
         if (s < 4 * 1024 || s > 1024 * 1024) {          if (s < 4 * 1024 || s > 1024 * 1024) {
                 logit("packet_set_maxsize: bad size %d", s);                  log("packet_set_maxsize: bad size %d", s);
                 return -1;                  return -1;
         }          }
         called = 1;          called = 1;

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