Debian Codegraph @

debian/patches/00_fix_incorrect_array_size

raw
1 Description: Fix incorrect bounds check when reading request headers
2 Author: Emmanuel Bouthenot <[email protected]>
3 Bug-Debian: https://bugs.debian.org/702667
4 Forwarded: no
5 Last-Update: 2019-02-18
6 ---
7 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
8 --- a/req.h
9 +++ b/req.h
10 @@ -1,5 +1,7 @@
11 #define HAD_REQ_H
12
13 +#define MAX_HEADERS 32
14 +
15 struct clinfo {
16 char name[128];
17 char ip[128];
18 @@ -21,7 +23,7 @@
19 char tstamp[32];
20 char ctype[32];
21
22 - char *header[32];
23 + char *header[MAX_HEADERS];
24
25 char fname[256];
26 char lname[257];
27 --- a/request.c
28 +++ b/request.c
29 @@ -189,7 +189,7 @@
30 char *b, *p;
31
32 i = 0;
33 - while ((len = getline(cl, buf, sizeof(buf))) > 0 && i < sizeof(r->header) - 1) {
34 + while ((len = getline(cl, buf, sizeof(buf))) > 0 && i < MAX_HEADERS - 1) {
35 b = buf;
36 while (isspace((int) *b) && *(b++) != '\0');
37 if (*b == '\0')
38 @@ -210,7 +210,7 @@
39 }
40 r->header[i] = NULL;
41
42 - if (i >= sizeof(r->header) - 1)
43 + if (i >= MAX_HEADERS - 1)
44 return 1;
45
46 return 0;
47 @@ -493,7 +493,7 @@
48 }
49 if (r->type != CONNECT) {
50 i = 0;
51 - while ((len = getline(s, buf, sizeof(buf))) > 0 && i < sizeof(r->header) - 1) {
52 + while ((len = getline(s, buf, sizeof(buf))) > 0 && i < MAX_HEADERS - 1) {
53 DEBUG(("do_request() => got remote header line: (%s)", buf));
54 r->header[i] = (char *) my_alloc(len + 1);
55 (void) strcpy(r->header[i++], buf);
56 --- a/filter.c
57 +++ b/filter.c
58 @@ -56,7 +56,7 @@
59
60 i = 0;
61 start_over:
62 - while (r->header[i] != NULL && i < sizeof(r->header) - 2) {
63 + while (r->header[i] != NULL && i < MAX_HEADERS - 2) {
64 DEBUG(("filter_request() => header entry %d (%s)", i, r->header[i]));
65
66 if (strncasecmp(r->header[i], loop_header, strlen(loop_header)) == 0) {
67 @@ -104,7 +104,7 @@
68
69 i++;
70 j = 0;
71 - while (f_hdr_add[j] != NULL && i < sizeof(r->header) - 1) {
72 + while (f_hdr_add[j] != NULL && i < MAX_HEADERS - 1) {
73 r->header[i] = (char *) my_alloc(strlen(f_hdr_add[j]) + 1);
74 (void) strcpy(r->header[i], f_hdr_add[j]);
75
76 @@ -166,7 +166,7 @@
77 i++;
78
79 }
80 - if(r->kalive && i - 2 < sizeof(r->header)) {
81 + if(r->kalive && i - 2 < MAX_HEADERS) {
82 r->header[i] = (char *) my_alloc(strlen(http_pkalive) + 1);
83 (void) strcpy(r->header[i], http_pkalive);
84 r->header[++i] = (char *) my_alloc(strlen(http_kalive) + 1);