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

Diff for /src/usr.bin/ssh/ssh.c between version 1.149 and 1.150

version 1.149, 2001/10/24 08:51:35 version 1.150, 2001/11/30 20:39:28
Line 767 
Line 767 
 }  }
   
 static void  static void
 x11_get_proto(char *proto, int proto_len, char *data, int data_len)  x11_get_proto(char **_proto, char **_data)
 {  {
         char line[512];          char line[512];
           static char proto[512], data[512];
         FILE *f;          FILE *f;
         int got_data = 0, i;          int got_data = 0, i;
   
           *_proto = proto;
           *_data = data;
           proto[0] = data[0] = '\0';
         if (options.xauth_location) {          if (options.xauth_location) {
                 /* Try to get Xauthority information for the display. */                  /* Try to get Xauthority information for the display. */
                 snprintf(line, sizeof line, "%.100s list %.200s 2>" _PATH_DEVNULL,                  snprintf(line, sizeof line, "%.100s list %.200s 2>" _PATH_DEVNULL,
                     options.xauth_location, getenv("DISPLAY"));                      options.xauth_location, getenv("DISPLAY"));
                 f = popen(line, "r");                  f = popen(line, "r");
                 if (f && fgets(line, sizeof(line), f) &&                  if (f && fgets(line, sizeof(line), f) &&
                     sscanf(line, "%*s %s %s", proto, data) == 2)                      sscanf(line, "%*s %511s %511s", proto, data) == 2)
                         got_data = 1;                          got_data = 1;
                 if (f)                  if (f)
                         pclose(f);                          pclose(f);
Line 795 
Line 799 
         if (!got_data) {          if (!got_data) {
                 u_int32_t rand = 0;                  u_int32_t rand = 0;
   
                 strlcpy(proto, "MIT-MAGIC-COOKIE-1", proto_len);                  strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto);
                 for (i = 0; i < 16; i++) {                  for (i = 0; i < 16; i++) {
                         if (i % 4 == 0)                          if (i % 4 == 0)
                                 rand = arc4random();                                  rand = arc4random();
                         snprintf(data + 2 * i, data_len - 2 * i, "%02x", rand & 0xff);                          snprintf(data + 2 * i, sizeof data - 2 * i, "%02x", rand & 0xff);
                         rand >>= 8;                          rand >>= 8;
                 }                  }
         }          }
Line 923 
Line 927 
         }          }
         /* Request X11 forwarding if enabled and DISPLAY is set. */          /* Request X11 forwarding if enabled and DISPLAY is set. */
         if (options.forward_x11 && getenv("DISPLAY") != NULL) {          if (options.forward_x11 && getenv("DISPLAY") != NULL) {
                 char proto[512], data[512];                  char *proto, *data;
                 /* Get reasonable local authentication information. */                  /* Get reasonable local authentication information. */
                 x11_get_proto(proto, sizeof proto, data, sizeof data);                  x11_get_proto(&proto, &data);
                 /* Request forwarding with authentication spoofing. */                  /* Request forwarding with authentication spoofing. */
                 debug("Requesting X11 forwarding with authentication spoofing.");                  debug("Requesting X11 forwarding with authentication spoofing.");
                 x11_request_forwarding_with_spoofing(0, proto, data);                  x11_request_forwarding_with_spoofing(0, proto, data);
Line 1039 
Line 1043 
         }          }
         if (options.forward_x11 &&          if (options.forward_x11 &&
             getenv("DISPLAY") != NULL) {              getenv("DISPLAY") != NULL) {
                 char proto[512], data[512];                  char *proto, *data;
                 /* Get reasonable local authentication information. */                  /* Get reasonable local authentication information. */
                 x11_get_proto(proto, sizeof proto, data, sizeof data);                  x11_get_proto(&proto, &data);
                 /* Request forwarding with authentication spoofing. */                  /* Request forwarding with authentication spoofing. */
                 debug("Requesting X11 forwarding with authentication spoofing.");                  debug("Requesting X11 forwarding with authentication spoofing.");
                 x11_request_forwarding_with_spoofing(id, proto, data);                  x11_request_forwarding_with_spoofing(id, proto, data);

Legend:
Removed from v.1.149  
changed lines
  Added in v.1.150