Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/dist/ipf/lib/Attic/load_http.c between versions 1.1 and 1.2

version 1.1, 2007/04/14 20:17:31 version 1.2, 2009/05/07 21:07:34
Line 17  alist_t * Line 17  alist_t *
 load_http(char *url)  load_http(char *url)
 {  {
         int fd, len, left, port, endhdr, removed;          int fd, len, left, port, endhdr, removed;
         char *s, *t, *u, buffer[1024], *myurl;          size_t rem;
           char *s, *t, *u, buffer[2048], *myurl;
         alist_t *a, *rtop, *rbot;          alist_t *a, *rtop, *rbot;
         struct sockaddr_in sin;          struct sockaddr_in sin;
         struct hostent *host;          struct hostent *host;
Line 34  load_http(char *url) Line 35  load_http(char *url)
         rtop = NULL;          rtop = NULL;
         rbot = NULL;          rbot = NULL;
   
         sprintf(buffer, "GET %s HTTP/1.0\r\n", url);          rem = sizeof(buffer);
           left = snprintf(buffer, rem, "GET %s HTTP/1.0\r\n", url);
           if (left < 0 || left > rem)
                   goto done;
           rem -= left;
   
         myurl = strdup(url);          myurl = strdup(url);
         if (myurl == NULL)          if (myurl == NULL)
Line 44  load_http(char *url) Line 49  load_http(char *url)
         t = strchr(s, '/');          t = strchr(s, '/');
         if (t == NULL) {          if (t == NULL) {
                 fprintf(stderr, "load_http has a malformed URL '%s'\n", url);                  fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
                 free(myurl);                  goto done;
                 return NULL;  
         }          }
         *t++ = '\0';          *t++ = '\0';
   
Line 53  load_http(char *url) Line 57  load_http(char *url)
         if (u != NULL)          if (u != NULL)
                 s = u + 1;              /* AUTH */                  s = u + 1;              /* AUTH */
   
         sprintf(buffer + strlen(buffer), "Host: %s\r\n\r\n", s);          left = snprintf(buffer + left, rem, "Host: %s\r\n\r\n", s);
           if (left < 0 || left > rem)
                   goto done;
           rem -= left;
   
         u = strchr(s, ':');          u = strchr(s, ':');
         if (u != NULL) {          if (u != NULL) {
Line 69  load_http(char *url) Line 76  load_http(char *url)
         sin.sin_family = AF_INET;          sin.sin_family = AF_INET;
         sin.sin_port = htons(port);          sin.sin_port = htons(port);
   
         if (isdigit(*s)) {          if (isdigit((unsigned char)*s)) {
                 if (inet_aton(s, &sin.sin_addr) == -1) {                  if (inet_aton(s, &sin.sin_addr) == -1) {
                         goto done;                          goto done;
                 }                  }
Line 85  load_http(char *url) Line 92  load_http(char *url)
         if (fd == -1)          if (fd == -1)
                 goto done;                  goto done;
   
         if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {          if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1)
                 close(fd);  
                 goto done;                  goto done;
         }  
   
         len = strlen(buffer);          len = strlen(buffer);
         if (write(fd, buffer, len) != len) {          if (write(fd, buffer, len) != len)
                 close(fd);  
                 goto done;                  goto done;
         }  
   
         s = buffer;          s = buffer;
         endhdr = 0;          endhdr = 0;
Line 144  load_http(char *url) Line 147  load_http(char *url)
                                 break;                                  break;
   
                         *t++ = '\0';                          *t++ = '\0';
                         for (u = buffer; isdigit(*u) || (*u == '.'); u++)                          for (u = buffer; isdigit((unsigned char)*u) ||
                                 ;                              (*u == '.'); u++)
                                   continue;
                         if (*u == '/') {                          if (*u == '/') {
                                 char *slash;                                  char *slash;
   
                                 slash = u;                                  slash = u;
                                 u++;                                  u++;
                                 while (isdigit(*u))                                  while (isdigit((unsigned char)*u))
                                         u++;                                          u++;
                                 if (!isspace(*u) && *u)                                  if (!isspace((unsigned char)*u) && *u)
                                         u = slash;                                          u = slash;
                         }                          }
                         *u = '\0';                          *u = '\0';

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb <webmaster@jp.NetBSD.org>