diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-08-30 19:17:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-08-30 19:17:17 +0000 |
commit | a22321bf1a3187ae9eaf0789ec477f2c9c7d81f7 (patch) | |
tree | 793603d4dbcff33b011343ebece254be68ea9db2 /src/daemon | |
parent | bf92eff1f850b9d2ed436bc05f163457007cbdef (diff) | |
download | libmicrohttpd-a22321bf1a3187ae9eaf0789ec477f2c9c7d81f7.tar.gz libmicrohttpd-a22321bf1a3187ae9eaf0789ec477f2c9c7d81f7.zip |
fixing #2531
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/connection.c | 66 | ||||
-rw-r--r-- | src/daemon/digestauth.c | 16 | ||||
-rw-r--r-- | src/daemon/postprocessor.c | 2 | ||||
-rw-r--r-- | src/daemon/response.c | 12 |
4 files changed, 64 insertions, 32 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index beb44420..4c5653af 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -1123,26 +1123,58 @@ parse_arguments (enum MHD_ValueKind kind, | |||
1123 | 1123 | ||
1124 | while (NULL != args) | 1124 | while (NULL != args) |
1125 | { | 1125 | { |
1126 | if (NULL == (equals = strstr (args, "="))) | 1126 | equals = strchr (args, '='); |
1127 | amper = strchr (args, '&'); | ||
1128 | if (NULL == amper) | ||
1127 | { | 1129 | { |
1128 | /* add with 'value' NULL */ | 1130 | /* last argument */ |
1131 | if (NULL == equals) | ||
1132 | { | ||
1133 | /* got 'foo', add key 'foo' with NULL for value */ | ||
1134 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, | ||
1135 | connection, | ||
1136 | args); | ||
1137 | return connection_add_header (connection, | ||
1138 | args, | ||
1139 | NULL, | ||
1140 | kind); | ||
1141 | } | ||
1142 | /* got 'foo=bar' */ | ||
1143 | equals[0] = '\0'; | ||
1144 | equals++; | ||
1145 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, | ||
1146 | connection, | ||
1147 | args); | ||
1148 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, | ||
1149 | connection, | ||
1150 | equals); | ||
1151 | return connection_add_header (connection, args, equals, kind); | ||
1152 | } | ||
1153 | /* amper is non-NULL here */ | ||
1154 | amper[0] = '\0'; | ||
1155 | amper++; | ||
1156 | if ( (NULL == equals) || | ||
1157 | (equals >= amper) ) | ||
1158 | { | ||
1159 | /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ | ||
1129 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, | 1160 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, |
1130 | connection, | 1161 | connection, |
1131 | args); | 1162 | args); |
1132 | 1163 | if (MHD_NO == | |
1133 | return connection_add_header (connection, | 1164 | connection_add_header (connection, |
1134 | args, | 1165 | args, |
1135 | NULL, | 1166 | NULL, |
1136 | kind); | 1167 | kind)) |
1168 | return MHD_NO; | ||
1169 | /* continue with 'bar' */ | ||
1170 | args = amper; | ||
1171 | continue; | ||
1172 | |||
1137 | } | 1173 | } |
1174 | /* equals and amper are non-NULL here, and equals < amper, | ||
1175 | so we got regular 'foo=value&bar...'-kind of argument */ | ||
1138 | equals[0] = '\0'; | 1176 | equals[0] = '\0'; |
1139 | equals++; | 1177 | equals++; |
1140 | amper = strstr (equals, "&"); | ||
1141 | if (amper != NULL) | ||
1142 | { | ||
1143 | amper[0] = '\0'; | ||
1144 | amper++; | ||
1145 | } | ||
1146 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, | 1178 | connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, |
1147 | connection, | 1179 | connection, |
1148 | args); | 1180 | args); |
@@ -1265,14 +1297,14 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) | |||
1265 | char *httpVersion; | 1297 | char *httpVersion; |
1266 | char *args; | 1298 | char *args; |
1267 | 1299 | ||
1268 | if (NULL == (uri = strstr (line, " "))) | 1300 | if (NULL == (uri = strchr (line, ' '))) |
1269 | return MHD_NO; /* serious error */ | 1301 | return MHD_NO; /* serious error */ |
1270 | uri[0] = '\0'; | 1302 | uri[0] = '\0'; |
1271 | connection->method = line; | 1303 | connection->method = line; |
1272 | uri++; | 1304 | uri++; |
1273 | while (uri[0] == ' ') | 1305 | while (uri[0] == ' ') |
1274 | uri++; | 1306 | uri++; |
1275 | httpVersion = strstr (uri, " "); | 1307 | httpVersion = strchr (uri, ' '); |
1276 | if (httpVersion != NULL) | 1308 | if (httpVersion != NULL) |
1277 | { | 1309 | { |
1278 | httpVersion[0] = '\0'; | 1310 | httpVersion[0] = '\0'; |
@@ -1283,7 +1315,7 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) | |||
1283 | = | 1315 | = |
1284 | connection->daemon->uri_log_callback (connection->daemon-> | 1316 | connection->daemon->uri_log_callback (connection->daemon-> |
1285 | uri_log_callback_cls, uri); | 1317 | uri_log_callback_cls, uri); |
1286 | args = strstr (uri, "?"); | 1318 | args = strchr (uri, '?'); |
1287 | if (NULL != args) | 1319 | if (NULL != args) |
1288 | { | 1320 | { |
1289 | args[0] = '\0'; | 1321 | args[0] = '\0'; |
@@ -1638,7 +1670,7 @@ process_header_line (struct MHD_Connection *connection, char *line) | |||
1638 | char *colon; | 1670 | char *colon; |
1639 | 1671 | ||
1640 | /* line should be normal header line, find colon */ | 1672 | /* line should be normal header line, find colon */ |
1641 | colon = strstr (line, ":"); | 1673 | colon = strchr (line, ':'); |
1642 | if (colon == NULL) | 1674 | if (colon == NULL) |
1643 | { | 1675 | { |
1644 | /* error in header line, die hard */ | 1676 | /* error in header line, die hard */ |
diff --git a/src/daemon/digestauth.c b/src/daemon/digestauth.c index 1f9547c5..081064a3 100644 --- a/src/daemon/digestauth.c +++ b/src/daemon/digestauth.c | |||
@@ -225,20 +225,20 @@ lookup_sub_value(char *dest, | |||
225 | return 0; | 225 | return 0; |
226 | while ('\0' != *ptr) | 226 | while ('\0' != *ptr) |
227 | { | 227 | { |
228 | if (NULL == (eq = strstr (ptr, "="))) | 228 | if (NULL == (eq = strchr (ptr, '='))) |
229 | return 0; | 229 | return 0; |
230 | q1 = eq + 1; | 230 | q1 = eq + 1; |
231 | while (' ' == *q1) | 231 | while (' ' == *q1) |
232 | q1++; | 232 | q1++; |
233 | if ('\"' != *q1) | 233 | if ('\"' != *q1) |
234 | { | 234 | { |
235 | q2 = strstr (q1, ","); | 235 | q2 = strchr (q1, ','); |
236 | qn = q2; | 236 | qn = q2; |
237 | } | 237 | } |
238 | else | 238 | else |
239 | { | 239 | { |
240 | q1++; | 240 | q1++; |
241 | q2 = strstr (q1, "\""); | 241 | q2 = strchr (q1, '\"'); |
242 | if (NULL == q2) | 242 | if (NULL == q2) |
243 | return 0; /* end quote not found */ | 243 | return 0; /* end quote not found */ |
244 | qn = q2 + 1; | 244 | qn = q2 + 1; |
@@ -274,7 +274,7 @@ lookup_sub_value(char *dest, | |||
274 | } | 274 | } |
275 | if (NULL == qn) | 275 | if (NULL == qn) |
276 | return 0; | 276 | return 0; |
277 | ptr = strstr (qn, ","); | 277 | ptr = strchr (qn, ','); |
278 | if (NULL == ptr) | 278 | if (NULL == ptr) |
279 | return 0; | 279 | return 0; |
280 | ptr++; | 280 | ptr++; |
@@ -490,7 +490,7 @@ check_argument_match (struct MHD_Connection *connection, | |||
490 | while ( (argp != NULL) && | 490 | while ( (argp != NULL) && |
491 | (argp[0] != '\0') ) | 491 | (argp[0] != '\0') ) |
492 | { | 492 | { |
493 | equals = strstr (argp, "="); | 493 | equals = strchr (argp, '='); |
494 | if (equals == NULL) | 494 | if (equals == NULL) |
495 | { | 495 | { |
496 | /* add with 'value' NULL */ | 496 | /* add with 'value' NULL */ |
@@ -504,7 +504,7 @@ check_argument_match (struct MHD_Connection *connection, | |||
504 | } | 504 | } |
505 | equals[0] = '\0'; | 505 | equals[0] = '\0'; |
506 | equals++; | 506 | equals++; |
507 | amper = strstr (equals, "&"); | 507 | amper = strchr (equals, '&'); |
508 | if (amper != NULL) | 508 | if (amper != NULL) |
509 | { | 509 | { |
510 | amper[0] = '\0'; | 510 | amper[0] = '\0'; |
@@ -639,7 +639,7 @@ MHD_digest_auth_check(struct MHD_Connection *connection, | |||
639 | return MHD_NO; | 639 | return MHD_NO; |
640 | } | 640 | } |
641 | { | 641 | { |
642 | const char *args = strstr (uri, "?"); | 642 | const char *args = strchr (uri, '?'); |
643 | if (args == NULL) | 643 | if (args == NULL) |
644 | args = ""; | 644 | args = ""; |
645 | else | 645 | else |
@@ -830,7 +830,7 @@ MHD_basic_auth_get_username_password(struct MHD_Connection *connection, | |||
830 | return NULL; | 830 | return NULL; |
831 | } | 831 | } |
832 | /* Find user:password pattern */ | 832 | /* Find user:password pattern */ |
833 | separator = strstr(decode, ":"); | 833 | separator = strchr (decode, ':'); |
834 | if (separator == NULL) | 834 | if (separator == NULL) |
835 | { | 835 | { |
836 | #if HAVE_MESSAGES | 836 | #if HAVE_MESSAGES |
diff --git a/src/daemon/postprocessor.c b/src/daemon/postprocessor.c index fe609952..1f3cef5c 100644 --- a/src/daemon/postprocessor.c +++ b/src/daemon/postprocessor.c | |||
@@ -539,7 +539,7 @@ try_get_value (const char *buf, const char *key, char **destination) | |||
539 | } | 539 | } |
540 | if (spos[klen + 1] != '"') | 540 | if (spos[klen + 1] != '"') |
541 | return; /* not quoted */ | 541 | return; /* not quoted */ |
542 | if (NULL == (endv = strstr (&spos[klen + 2], "\""))) | 542 | if (NULL == (endv = strchr (&spos[klen + 2], '\"'))) |
543 | return; /* no end-quote */ | 543 | return; /* no end-quote */ |
544 | vlen = endv - spos - klen - 1; | 544 | vlen = endv - spos - klen - 1; |
545 | *destination = malloc (vlen); | 545 | *destination = malloc (vlen); |
diff --git a/src/daemon/response.c b/src/daemon/response.c index aa1e16d7..dbd034ad 100644 --- a/src/daemon/response.c +++ b/src/daemon/response.c | |||
@@ -50,12 +50,12 @@ add_response_entry (struct MHD_Response *response, | |||
50 | (NULL == content) || | 50 | (NULL == content) || |
51 | (0 == strlen (header)) || | 51 | (0 == strlen (header)) || |
52 | (0 == strlen (content)) || | 52 | (0 == strlen (content)) || |
53 | (NULL != strstr (header, "\t")) || | 53 | (NULL != strchr (header, '\t')) || |
54 | (NULL != strstr (header, "\r")) || | 54 | (NULL != strchr (header, '\r')) || |
55 | (NULL != strstr (header, "\n")) || | 55 | (NULL != strchr (header, '\n')) || |
56 | (NULL != strstr (content, "\t")) || | 56 | (NULL != strchr (content, '\t')) || |
57 | (NULL != strstr (content, "\r")) || | 57 | (NULL != strchr (content, '\r')) || |
58 | (NULL != strstr (content, "\n")) ) | 58 | (NULL != strchr (content, '\n')) ) |
59 | return MHD_NO; | 59 | return MHD_NO; |
60 | if (NULL == (hdr = malloc (sizeof (struct MHD_HTTP_Header)))) | 60 | if (NULL == (hdr = malloc (sizeof (struct MHD_HTTP_Header)))) |
61 | return MHD_NO; | 61 | return MHD_NO; |