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

Diff for /src/usr.bin/ftp/fetch.c between version 1.30 and 1.31

version 1.30, 2000/05/03 19:50:41 version 1.31, 2000/05/15 16:07:04
Line 619 
Line 619 
                  */                   */
                 host = line;                  host = line;
                 if (strncasecmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0) {                  if (strncasecmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
                           char *passend, *userend;
   
                         if (ftpproxy) {                          if (ftpproxy) {
                                 if (url_get(line, ftpproxy, outfile) == -1)                                  if (url_get(line, ftpproxy, outfile) == -1)
                                         rval = argpos + 1;                                          rval = argpos + 1;
Line 628 
Line 630 
                         dir = strchr(host, '/');                          dir = strchr(host, '/');
   
                         /* Look for [user:pass@]host[:port] */                          /* Look for [user:pass@]host[:port] */
                         pass = strpbrk(host, ":@/");  
                         if (pass == NULL || *pass == '/') {                          /* check if we have "user:pass@" */
                                 pass = NULL;                          passend = strchr(host, '@');
                                 goto parsed_url;                          userend = strchr(host, ':');
                         }                          if (passend && userend && userend < passend &&
                         if (pass == host || *pass == '@') {                              (!dir || passend < dir)) {
                                   user = host;
                                   pass = userend + 1;
                                   host = passend + 1;
                                   *userend = *passend = '\0';
   
                                   if (EMPTYSTRING(user) || EMPTYSTRING(pass)) {
 bad_ftp_url:  bad_ftp_url:
                                 warnx("Invalid URL: %s", argv[argpos]);                                          warnx("Invalid URL: %s", argv[argpos]);
                                 rval = argpos + 1;                                          rval = argpos + 1;
                                 continue;                                          continue;
                                   }
                         }                          }
                         *pass++ = '\0';  
                         /* XXX - assumes no '@' in pathname */  
                         if ((cp = strrchr(pass, '@')) == NULL)  
                                 cp = strpbrk(pass, ":@/");  
                         if (cp == NULL || *cp == '/') {  
                                 portnum = pass;  
                                 pass = NULL;  
                                 goto parsed_url;  
                         }  
                         if (EMPTYSTRING(cp) || *cp == ':')  
                                 goto bad_ftp_url;  
                         *cp++ = '\0';  
                         user = host;  
                         if (EMPTYSTRING(user))  
                                 goto bad_ftp_url;  
                         host = cp;  
   
 #if 0  #ifdef INET6
                         /* look for IPv6 address URL */                          /* check [host]:port, or [host] */
                         if (host == '[' && (cp = strrchr(host, ']'))) {                          if (host[0] == '[') {
                                 host++;                                  cp = strchr(host, ']');
                                 *cp++ = '\0';                                  if (cp && (!dir || cp < dir)) {
                                           if (cp + 1 == dir || cp[1] == ':') {
                                                   host++;
                                                   *cp++ = '\0';
                                           } else
                                                   cp = NULL;
                                   } else
                                           cp = host;
                         } else                          } else
                                 cp = host;                                  cp = host;
   #else
                           cp = host;
 #endif  #endif
   
                         portnum = strrchr(cp, ':');                          /* split off host[:port] if there is */
                         if (portnum != NULL)                          if (cp) {
                                 *portnum++ = '\0';                                  portnum = strchr(cp, ':');
                                   if (!portnum)
                                           ;
                                   else {
                                           if (!dir)
                                                   ;
                                           else if (portnum + 1 < dir) {
                                                   *portnum++ = '\0';
                                                   /*
                                                    * XXX should check if portnum
                                                    * is decimal number
                                                    */
                                           } else {
                                                   /* empty portnum */
                                                   goto bad_ftp_url;
                                           }
                                   }
                           } else
                                   portnum = NULL;
                 } else {                        /* classic style `host:file' */                  } else {                        /* classic style `host:file' */
                         dir = strchr(host, ':');                          dir = strchr(host, ':');
                 }                  }
 parsed_url:  
                 if (EMPTYSTRING(host)) {                  if (EMPTYSTRING(host)) {
                         rval = argpos + 1;                          rval = argpos + 1;
                         continue;                          continue;

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31