diff options
Diffstat (limited to 'web/attachments/227858-check_httppatch.txt')
-rw-r--r-- | web/attachments/227858-check_httppatch.txt | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/web/attachments/227858-check_httppatch.txt b/web/attachments/227858-check_httppatch.txt new file mode 100644 index 0000000..08bf2ff --- /dev/null +++ b/web/attachments/227858-check_httppatch.txt | |||
@@ -0,0 +1,103 @@ | |||
1 | --- check_http.c 2007-03-06 14:45:57.000000000 -0800 | ||
2 | +++ - 2007-05-04 11:00:35.226089000 -0700 | ||
3 | @@ -110,7 +110,7 @@ | ||
4 | int http_opt_headers_count = 0; | ||
5 | int onredirect = STATE_OK; | ||
6 | int use_ssl = FALSE; | ||
7 | -int verbose = FALSE; | ||
8 | +int verbose = TRUE; | ||
9 | int sd; | ||
10 | int min_page_len = 0; | ||
11 | int max_page_len = 0; | ||
12 | @@ -751,6 +751,17 @@ | ||
13 | char *header; | ||
14 | char *page; | ||
15 | char *auth; | ||
16 | +/* Patched by T.P -- binary data */ | ||
17 | + char bindata[MAX_INPUT_BUFFER]; | ||
18 | + int bindatalen = 0; | ||
19 | + int bindatafound = 0; | ||
20 | + int bufpos=0; | ||
21 | + int mybuflen=0; | ||
22 | + char *pointer = http_post_data; | ||
23 | + unsigned long ascii = 0; | ||
24 | + char code[3] = {0}; | ||
25 | + char *end = NULL; | ||
26 | +/* End patch */ | ||
27 | int http_status; | ||
28 | int i = 0; | ||
29 | size_t pagesize = 0; | ||
30 | @@ -800,14 +811,42 @@ | ||
31 | |||
32 | /* either send http POST data */ | ||
33 | if (http_post_data) { | ||
34 | +/* Patched by T.P -- binary data */ | ||
35 | + while (*pointer) { | ||
36 | + if (*pointer == '%') { | ||
37 | + /* Interpret the next two hex chars -- no error checking */ | ||
38 | + memcpy(code,++pointer,2); | ||
39 | + ascii = strtoul(code,&end,16); | ||
40 | + bindata[bindatalen] = (char)ascii; | ||
41 | + pointer += 2; | ||
42 | + } else if (*pointer == '\\') { | ||
43 | + /* Skip the escape char -- no error checking */ | ||
44 | + pointer++; | ||
45 | + bindata[bindatalen++] = *pointer++; | ||
46 | + } else { | ||
47 | + /* Just copy the char */ | ||
48 | + bindata[bindatalen] = *pointer++; | ||
49 | + } | ||
50 | + bindatalen++; | ||
51 | + } | ||
52 | + /* Truncate the original string at the shorter length for future use */ | ||
53 | + http_post_data[bindatalen] = (char)0; | ||
54 | +/* End patch */ | ||
55 | if (http_content_type) { | ||
56 | asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); | ||
57 | } else { | ||
58 | asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); | ||
59 | } | ||
60 | |||
61 | +/* Patched by T.P -- binary data */ | ||
62 | + /* original line | ||
63 | asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); | ||
64 | + */ | ||
65 | + asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, bindatalen); | ||
66 | + /* Print the original (ascii, truncated) string to fill space */ | ||
67 | asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); | ||
68 | + bufpos = strlen(buf) - bindatalen - 2; | ||
69 | +/* End patch */ | ||
70 | } | ||
71 | else { | ||
72 | /* or just a newline so the server knows we're done with the request */ | ||
73 | @@ -815,13 +854,29 @@ | ||
74 | } | ||
75 | |||
76 | if (verbose) printf ("%s\n", buf); | ||
77 | - my_send (buf, strlen (buf)); | ||
78 | +/* Patched by T.P -- binary data */ | ||
79 | + if (bindatalen) { | ||
80 | + mybuflen = strlen(buf); | ||
81 | + /* Overwrite it with the (possibly) binary data */ | ||
82 | + for (i=0;i<bindatalen;i++) { | ||
83 | + buf[i+bufpos] = bindata[i]; | ||
84 | + } | ||
85 | + my_send (buf, mybuflen); | ||
86 | + } else { | ||
87 | + /* original line */ | ||
88 | + my_send (buf, strlen (buf)); | ||
89 | + } | ||
90 | |||
91 | /* fetch the page */ | ||
92 | full_page = strdup(""); | ||
93 | + pointer=full_page; | ||
94 | while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) { | ||
95 | + /* Original lines | ||
96 | buffer[i] = '\0'; | ||
97 | asprintf (&full_page, "%s%s", full_page, buffer); | ||
98 | + */ | ||
99 | + memcpy(pointer+pagesize,buffer,i); | ||
100 | +/* End patch */ | ||
101 | pagesize += i; | ||
102 | |||
103 | if (no_body && document_headers_done (full_page)) { \ No newline at end of file | ||