Lines 231-237
char *httpauth1 = NULL;
Link Here
|
231 |
int http_open (char *url) |
231 |
int http_open (char *url) |
232 |
{ |
232 |
{ |
233 |
char *purl, *host, *request, *sptr; |
233 |
char *purl, *host, *request, *sptr; |
234 |
unsigned int linelength, linelengthbase; |
234 |
unsigned int linelength, linelengthbase, purl_length; |
235 |
unsigned long myip; |
235 |
unsigned long myip; |
236 |
unsigned char *myport; |
236 |
unsigned char *myport; |
237 |
int sock; |
237 |
int sock; |
Lines 275-282
int http_open (char *url)
Link Here
|
275 |
exit(1); |
275 |
exit(1); |
276 |
} |
276 |
} |
277 |
|
277 |
|
278 |
/* The length of purl is upper bound by 3*strlen(url) + 1 if everything in it is a space */ |
278 |
/* |
279 |
purl = (char *)malloc(sizeof(char) * (strlen(url)*3 + 1)); |
279 |
* The length of purl is upper bound by 3*strlen(url) + 1 if everything |
|
|
280 |
* in it is a space. For HTTP redirections, we need something longer; |
281 |
* 1024 bytes were arbitrarily chosen. |
282 |
*/ |
283 |
purl_length = strlen(url) * 3 + 1; |
284 |
if (purl_length < 1024) purl_length = 1024; |
285 |
purl = (char *)malloc(sizeof(char) * purl_length); |
280 |
if (!purl) { |
286 |
if (!purl) { |
281 |
fprintf (stderr, "malloc() failed, out of memory.\n"); |
287 |
fprintf (stderr, "malloc() failed, out of memory.\n"); |
282 |
exit (1); |
288 |
exit (1); |
Lines 479-486
fail:
Link Here
|
479 |
} |
485 |
} |
480 |
do { |
486 |
do { |
481 |
readstring (request, linelength-1, myfile); |
487 |
readstring (request, linelength-1, myfile); |
482 |
if (!strncmp(request, "Location:", 9)) |
488 |
if (!strncmp(request, "Location:", 9)) { |
483 |
strncpy (purl, request+10, 1023); |
489 |
strncpy (purl, request+10, purl_length); |
|
|
490 |
purl[purl_length - 1] = 0; |
491 |
} |
484 |
} while (request[0] != '\r' && request[0] != '\n'); |
492 |
} while (request[0] != '\r' && request[0] != '\n'); |
485 |
|
493 |
|
486 |
free(request); |
494 |
free(request); |