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

Diff for /src/usr.bin/ssh/channels.c between version 1.320 and 1.321

version 1.320, 2013/04/06 16:07:00 version 1.321, 2013/05/17 00:13:13
Line 396 
Line 396 
   
         s = channel_open_message();          s = channel_open_message();
         debug3("channel %d: status: %s", c->self, s);          debug3("channel %d: status: %s", c->self, s);
         xfree(s);          free(s);
   
         if (c->sock != -1)          if (c->sock != -1)
                 shutdown(c->sock, SHUT_RDWR);                  shutdown(c->sock, SHUT_RDWR);
Line 404 
Line 404 
         buffer_free(&c->input);          buffer_free(&c->input);
         buffer_free(&c->output);          buffer_free(&c->output);
         buffer_free(&c->extended);          buffer_free(&c->extended);
         if (c->remote_name) {          free(c->remote_name);
                 xfree(c->remote_name);          c->remote_name = NULL;
                 c->remote_name = NULL;          free(c->path);
         }          c->path = NULL;
         if (c->path) {          free(c->listening_addr);
                 xfree(c->path);          c->listening_addr = NULL;
                 c->path = NULL;  
         }  
         if (c->listening_addr) {  
                 xfree(c->listening_addr);  
                 c->listening_addr = NULL;  
         }  
         while ((cc = TAILQ_FIRST(&c->status_confirms)) != NULL) {          while ((cc = TAILQ_FIRST(&c->status_confirms)) != NULL) {
                 if (cc->abandon_cb != NULL)                  if (cc->abandon_cb != NULL)
                         cc->abandon_cb(c, cc->ctx);                          cc->abandon_cb(c, cc->ctx);
                 TAILQ_REMOVE(&c->status_confirms, cc, entry);                  TAILQ_REMOVE(&c->status_confirms, cc, entry);
                 bzero(cc, sizeof(*cc));                  bzero(cc, sizeof(*cc));
                 xfree(cc);                  free(cc);
         }          }
         if (c->filter_cleanup != NULL && c->filter_ctx != NULL)          if (c->filter_cleanup != NULL && c->filter_ctx != NULL)
                 c->filter_cleanup(c->self, c->filter_ctx);                  c->filter_cleanup(c->self, c->filter_ctx);
         channels[c->self] = NULL;          channels[c->self] = NULL;
         xfree(c);          free(c);
 }  }
   
 void  void
Line 1075 
Line 1069 
         strlcpy(username, p, sizeof(username));          strlcpy(username, p, sizeof(username));
         buffer_consume(&c->input, len);          buffer_consume(&c->input, len);
   
         if (c->path != NULL) {          free(c->path);
                 xfree(c->path);          c->path = NULL;
                 c->path = NULL;  
         }  
         if (need == 1) {                        /* SOCKS4: one string */          if (need == 1) {                        /* SOCKS4: one string */
                 host = inet_ntoa(s4_req.dest_addr);                  host = inet_ntoa(s4_req.dest_addr);
                 c->path = xstrdup(host);                  c->path = xstrdup(host);
Line 1211 
Line 1203 
         buffer_get(&c->input, (char *)&dest_addr, addrlen);          buffer_get(&c->input, (char *)&dest_addr, addrlen);
         buffer_get(&c->input, (char *)&dest_port, 2);          buffer_get(&c->input, (char *)&dest_port, 2);
         dest_addr[addrlen] = '\0';          dest_addr[addrlen] = '\0';
         if (c->path != NULL) {          free(c->path);
                 xfree(c->path);          c->path = NULL;
                 c->path = NULL;  
         }  
         if (s5_req.atyp == SSH_SOCKS5_DOMAIN) {          if (s5_req.atyp == SSH_SOCKS5_DOMAIN) {
                 if (addrlen >= NI_MAXHOST) {                  if (addrlen >= NI_MAXHOST) {
                         error("channel %d: dynamic request: socks5 hostname "                          error("channel %d: dynamic request: socks5 hostname "
Line 1374 
Line 1364 
                                 packet_put_cstring(buf);                                  packet_put_cstring(buf);
                         packet_send();                          packet_send();
                 }                  }
                 xfree(remote_ipaddr);                  free(remote_ipaddr);
         }          }
 }  }
   
Line 1388 
Line 1378 
   
         if (remote_port == -1) {          if (remote_port == -1) {
                 /* Fake addr/port to appease peers that validate it (Tectia) */                  /* Fake addr/port to appease peers that validate it (Tectia) */
                 xfree(remote_ipaddr);                  free(remote_ipaddr);
                 remote_ipaddr = xstrdup("127.0.0.1");                  remote_ipaddr = xstrdup("127.0.0.1");
                 remote_port = 65535;                  remote_port = 65535;
         }          }
Line 1401 
Line 1391 
             rtype, c->listening_port, c->path, c->host_port,              rtype, c->listening_port, c->path, c->host_port,
             remote_ipaddr, remote_port);              remote_ipaddr, remote_port);
   
         xfree(c->remote_name);          free(c->remote_name);
         c->remote_name = xstrdup(buf);          c->remote_name = xstrdup(buf);
   
         if (compat20) {          if (compat20) {
Line 1433 
Line 1423 
                         packet_put_cstring(c->remote_name);                          packet_put_cstring(c->remote_name);
                 packet_send();                  packet_send();
         }          }
         xfree(remote_ipaddr);          free(remote_ipaddr);
 }  }
   
 static void  static void
Line 1679 
Line 1669 
                 if (c->datagram) {                  if (c->datagram) {
                         /* ignore truncated writes, datagrams might get lost */                          /* ignore truncated writes, datagrams might get lost */
                         len = write(c->wfd, buf, dlen);                          len = write(c->wfd, buf, dlen);
                         xfree(data);                          free(data);
                         if (len < 0 && (errno == EINTR || errno == EAGAIN))                          if (len < 0 && (errno == EINTR || errno == EAGAIN))
                                 return 1;                                  return 1;
                         if (len <= 0) {                          if (len <= 0) {
Line 2203 
Line 2193 
                                                 debug("channel %d: datagram "                                                  debug("channel %d: datagram "
                                                     "too big for channel",                                                      "too big for channel",
                                                     c->self);                                                      c->self);
                                                 xfree(data);                                                  free(data);
                                                 continue;                                                  continue;
                                         }                                          }
                                         packet_start(SSH2_MSG_CHANNEL_DATA);                                          packet_start(SSH2_MSG_CHANNEL_DATA);
Line 2211 
Line 2201 
                                         packet_put_string(data, dlen);                                          packet_put_string(data, dlen);
                                         packet_send();                                          packet_send();
                                         c->remote_window -= dlen + 4;                                          c->remote_window -= dlen + 4;
                                         xfree(data);                                          free(data);
                                 }                                  }
                                 continue;                                  continue;
                         }                          }
Line 2383 
Line 2373 
         if (data_len > c->local_window) {          if (data_len > c->local_window) {
                 logit("channel %d: rcvd too much extended_data %d, win %d",                  logit("channel %d: rcvd too much extended_data %d, win %d",
                     c->self, data_len, c->local_window);                      c->self, data_len, c->local_window);
                 xfree(data);                  free(data);
                 return;                  return;
         }          }
         debug2("channel %d: rcvd ext data %d", c->self, data_len);          debug2("channel %d: rcvd ext data %d", c->self, data_len);
         c->local_window -= data_len;          c->local_window -= data_len;
         buffer_append(&c->extended, data, data_len);          buffer_append(&c->extended, data, data_len);
         xfree(data);          free(data);
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */
Line 2555 
Line 2545 
                 }                  }
                 logit("channel %d: open failed: %s%s%s", id,                  logit("channel %d: open failed: %s%s%s", id,
                     reason2txt(reason), msg ? ": ": "", msg ? msg : "");                      reason2txt(reason), msg ? ": ": "", msg ? msg : "");
                 if (msg != NULL)                  free(msg);
                         xfree(msg);                  free(lang);
                 if (lang != NULL)  
                         xfree(lang);  
                 if (c->open_confirm) {                  if (c->open_confirm) {
                         debug2("callback start");                          debug2("callback start");
                         c->open_confirm(c->self, 0, c->open_confirm_ctx);                          c->open_confirm(c->self, 0, c->open_confirm_ctx);
Line 2616 
Line 2604 
         packet_check_eom();          packet_check_eom();
         c = channel_connect_to(host, host_port,          c = channel_connect_to(host, host_port,
             "connected socket", originator_string);              "connected socket", originator_string);
         xfree(originator_string);          free(originator_string);
         xfree(host);          free(host);
         if (c == NULL) {          if (c == NULL) {
                 packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);                  packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);
                 packet_put_int(remote_id);                  packet_put_int(remote_id);
Line 2652 
Line 2640 
         cc->cb(type, c, cc->ctx);          cc->cb(type, c, cc->ctx);
         TAILQ_REMOVE(&c->status_confirms, cc, entry);          TAILQ_REMOVE(&c->status_confirms, cc, entry);
         bzero(cc, sizeof(*cc));          bzero(cc, sizeof(*cc));
         xfree(cc);          free(cc);
 }  }
   
 /* -- tcp forwarding */  /* -- tcp forwarding */
Line 3026 
Line 3014 
   
         permitted_opens[i].listen_port = 0;          permitted_opens[i].listen_port = 0;
         permitted_opens[i].port_to_connect = 0;          permitted_opens[i].port_to_connect = 0;
         xfree(permitted_opens[i].host_to_connect);          free(permitted_opens[i].host_to_connect);
         permitted_opens[i].host_to_connect = NULL;          permitted_opens[i].host_to_connect = NULL;
   
         return 0;          return 0;
Line 3065 
Line 3053 
             host_port, gateway_ports);              host_port, gateway_ports);
   
         /* Free the argument string. */          /* Free the argument string. */
         xfree(hostname);          free(hostname);
   
         return (success ? 0 : -1);          return (success ? 0 : -1);
 }  }
Line 3120 
Line 3108 
         } else {          } else {
                 permitted_opens[idx].listen_port = 0;                  permitted_opens[idx].listen_port = 0;
                 permitted_opens[idx].port_to_connect = 0;                  permitted_opens[idx].port_to_connect = 0;
                 xfree(permitted_opens[idx].host_to_connect);                  free(permitted_opens[idx].host_to_connect);
                 permitted_opens[idx].host_to_connect = NULL;                  permitted_opens[idx].host_to_connect = NULL;
         }          }
 }  }
Line 3153 
Line 3141 
         int i;          int i;
   
         for (i = 0; i < num_permitted_opens; i++)          for (i = 0; i < num_permitted_opens; i++)
                 if (permitted_opens[i].host_to_connect != NULL)                  free(permitted_opens[i].host_to_connect);
                         xfree(permitted_opens[i].host_to_connect);          free(permitted_opens);
         if (num_permitted_opens > 0) {          permitted_opens = NULL;
                 xfree(permitted_opens);  
                 permitted_opens = NULL;  
         }  
         num_permitted_opens = 0;          num_permitted_opens = 0;
 }  }
   
Line 3168 
Line 3153 
         int i;          int i;
   
         for (i = 0; i < num_adm_permitted_opens; i++)          for (i = 0; i < num_adm_permitted_opens; i++)
                 if (permitted_adm_opens[i].host_to_connect != NULL)                  free(permitted_adm_opens[i].host_to_connect);
                         xfree(permitted_adm_opens[i].host_to_connect);          free(permitted_adm_opens);
         if (num_adm_permitted_opens > 0) {          permitted_adm_opens = NULL;
                 xfree(permitted_adm_opens);  
                 permitted_adm_opens = NULL;  
         }  
         num_adm_permitted_opens = 0;          num_adm_permitted_opens = 0;
 }  }
   
Line 3267 
Line 3249 
 static void  static void
 channel_connect_ctx_free(struct channel_connect *cctx)  channel_connect_ctx_free(struct channel_connect *cctx)
 {  {
         xfree(cctx->host);          free(cctx->host);
         if (cctx->aitop)          if (cctx->aitop)
                 freeaddrinfo(cctx->aitop);                  freeaddrinfo(cctx->aitop);
         bzero(cctx, sizeof(*cctx));          bzero(cctx, sizeof(*cctx));
Line 3630 
Line 3612 
                 c->remote_id = remote_id;                  c->remote_id = remote_id;
                 c->force_drain = 1;                  c->force_drain = 1;
         }          }
         xfree(remote_host);          free(remote_host);
         if (c == NULL) {          if (c == NULL) {
                 /* Send refusal to the remote host. */                  /* Send refusal to the remote host. */
                 packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);                  packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);
Line 3738 
Line 3720 
         packet_put_int(screen_number);          packet_put_int(screen_number);
         packet_send();          packet_send();
         packet_write_wait();          packet_write_wait();
         xfree(new_data);          free(new_data);
 }  }
   
   

Legend:
Removed from v.1.320  
changed lines
  Added in v.1.321