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

Diff for /src/usr.bin/ssh/sshconnect.c between version 1.163 and 1.164

version 1.163, 2005/05/24 17:32:44 version 1.164, 2005/06/06 11:20:36
Line 55 
Line 55 
 static int  static int
 ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)  ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
 {  {
         Buffer command;          char *command_string, *tmp;
         const char *cp;  
         char *command_string;  
         int pin[2], pout[2];          int pin[2], pout[2];
         pid_t pid;          pid_t pid;
         char strport[NI_MAXSERV];          char strport[NI_MAXSERV];
           size_t len;
   
         /* Convert the port number into a string. */          /* Convert the port number into a string. */
         snprintf(strport, sizeof strport, "%hu", port);          snprintf(strport, sizeof strport, "%hu", port);
Line 72 
Line 71 
          * Use "exec" to avoid "sh -c" processes on some platforms           * Use "exec" to avoid "sh -c" processes on some platforms
          * (e.g. Solaris)           * (e.g. Solaris)
          */           */
         buffer_init(&command);          len = strlen(proxy_command) + 6;
         buffer_append(&command, "exec ", 5);          tmp = xmalloc(len);
           strlcpy(tmp, "exec ", len);
           strlcat(tmp, proxy_command, len);
           command_string = percent_expand(tmp, "h", host,
               "p", strport, (char *)NULL);
           xfree(tmp);
   
         for (cp = proxy_command; *cp; cp++) {  
                 if (cp[0] == '%' && cp[1] == '%') {  
                         buffer_append(&command, "%", 1);  
                         cp++;  
                         continue;  
                 }  
                 if (cp[0] == '%' && cp[1] == 'h') {  
                         buffer_append(&command, host, strlen(host));  
                         cp++;  
                         continue;  
                 }  
                 if (cp[0] == '%' && cp[1] == 'p') {  
                         buffer_append(&command, strport, strlen(strport));  
                         cp++;  
                         continue;  
                 }  
                 buffer_append(&command, cp, 1);  
         }  
         buffer_append(&command, "\0", 1);  
   
         /* Get the final command string. */  
         command_string = buffer_ptr(&command);  
   
         /* Create pipes for communicating with the proxy. */          /* Create pipes for communicating with the proxy. */
         if (pipe(pin) < 0 || pipe(pout) < 0)          if (pipe(pin) < 0 || pipe(pout) < 0)
                 fatal("Could not create pipes to communicate with the proxy: %.100s",                  fatal("Could not create pipes to communicate with the proxy: %.100s",
Line 150 
Line 131 
         close(pout[1]);          close(pout[1]);
   
         /* Free the command name. */          /* Free the command name. */
         buffer_free(&command);          xfree(command_string);
   
         /* Set the connection file descriptors. */          /* Set the connection file descriptors. */
         packet_set_connection(pout[0], pin[1]);          packet_set_connection(pout[0], pin[1]);

Legend:
Removed from v.1.163  
changed lines
  Added in v.1.164