Fri May 8 12:06:11 2009 UTC ()
reorder code to avoid uninitalized variable.


(christos)
diff -r1.2 -r1.3 src/dist/ipf/lib/load_http.c

cvs diff -r1.2 -r1.3 src/dist/ipf/lib/Attic/load_http.c (expand / switch to unified diff)

--- src/dist/ipf/lib/Attic/load_http.c 2009/05/07 21:07:34 1.2
+++ src/dist/ipf/lib/Attic/load_http.c 2009/05/08 12:06:11 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: load_http.c,v 1.2 2009/05/07 21:07:34 christos Exp $ */ 1/* $NetBSD: load_http.c,v 1.3 2009/05/08 12:06:11 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 2006 by Darren Reed. 4 * Copyright (C) 2006 by Darren Reed.
5 * 5 *
6 * See the IPFILTER.LICENCE file for details on licencing. 6 * See the IPFILTER.LICENCE file for details on licencing.
7 * 7 *
8 * Id: load_http.c,v 1.1.2.1 2006/08/25 21:13:04 darrenr Exp 8 * Id: load_http.c,v 1.1.2.1 2006/08/25 21:13:04 darrenr Exp
9 */ 9 */
10 10
11#include "ipf.h" 11#include "ipf.h"
12 12
13/* 13/*
14 * Format expected is one addres per line, at the start of each line. 14 * Format expected is one addres per line, at the start of each line.
@@ -25,36 +25,36 @@ load_http(char *url) @@ -25,36 +25,36 @@ load_http(char *url)
25 25
26 /* 26 /*
27 * More than this would just be absurd. 27 * More than this would just be absurd.
28 */ 28 */
29 if (strlen(url) > 512) { 29 if (strlen(url) > 512) {
30 fprintf(stderr, "load_http has a URL > 512 bytes?!\n"); 30 fprintf(stderr, "load_http has a URL > 512 bytes?!\n");
31 return NULL; 31 return NULL;
32 } 32 }
33 33
34 fd = -1; 34 fd = -1;
35 rtop = NULL; 35 rtop = NULL;
36 rbot = NULL; 36 rbot = NULL;
37 37
 38 myurl = strdup(url);
 39 if (myurl == NULL)
 40 goto done;
 41
38 rem = sizeof(buffer); 42 rem = sizeof(buffer);
39 left = snprintf(buffer, rem, "GET %s HTTP/1.0\r\n", url); 43 left = snprintf(buffer, rem, "GET %s HTTP/1.0\r\n", url);
40 if (left < 0 || left > rem) 44 if (left < 0 || left > rem)
41 goto done; 45 goto done;
42 rem -= left; 46 rem -= left;
43 47
44 myurl = strdup(url); 
45 if (myurl == NULL) 
46 goto done; 
47 
48 s = myurl + 7; /* http:// */ 48 s = myurl + 7; /* http:// */
49 t = strchr(s, '/'); 49 t = strchr(s, '/');
50 if (t == NULL) { 50 if (t == NULL) {
51 fprintf(stderr, "load_http has a malformed URL '%s'\n", url); 51 fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
52 goto done; 52 goto done;
53 } 53 }
54 *t++ = '\0'; 54 *t++ = '\0';
55 55
56 u = strchr(s, '@'); 56 u = strchr(s, '@');
57 if (u != NULL) 57 if (u != NULL)
58 s = u + 1; /* AUTH */ 58 s = u + 1; /* AUTH */
59 59
60 left = snprintf(buffer + left, rem, "Host: %s\r\n\r\n", s); 60 left = snprintf(buffer + left, rem, "Host: %s\r\n\r\n", s);