Skip to content

Commit 8ac3cb0

Browse files
author
grothoff
committed
fix #2733
git-svn-id: https://gnunet.org/svn/libmicrohttpd@25972 140774ce-b5e7-0310-ab8b-a85725594a96
1 parent b596c3b commit 8ac3cb0

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Fri Feb 1 10:19:44 CET 2013
2+
Handle case where POST data contains "key=" without value
3+
at the end and is not new-line terminated by invoking the
4+
callback with the "key" during MHD_destroy_post_processor (#2733). -CG
5+
16
Wed Jan 30 13:09:30 CET 2013
27
Adding more 'const' to allow keeping of reason phrases in ROM.
38
(see mailinglist). -CG/MV

src/daemon/postprocessor.c

+7
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,13 @@ MHD_destroy_post_processor (struct MHD_PostProcessor *pp)
10621062

10631063
if (NULL == pp)
10641064
return MHD_YES;
1065+
if (PP_ProcessValue == pp->state)
1066+
{
1067+
/* key without terminated value left at the end of the
1068+
buffer; fake receiving a termination character to
1069+
ensure it is also processed */
1070+
post_process_urlencoded (pp, "\n", 1);
1071+
}
10651072
/* These internal strings need cleaning up since
10661073
the post-processing may have been interrupted
10671074
at any stage */

src/daemon/postprocessor_test.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ const char *want[] = {
6060
"pics", "file2.gif", "image/gif", "binary", "filedata2",
6161
#define FORM_NESTED_END (FORM_NESTED_START + 15)
6262
NULL, NULL, NULL, NULL, NULL,
63-
#define URL_EMPTY_VALUE_DATA "key1=value1&key2="
63+
#define URL_EMPTY_VALUE_DATA "key1=value1&key2=&key3="
6464
#define URL_EMPTY_VALUE_START (FORM_NESTED_END + 5)
6565
"key1", NULL, NULL, NULL, "value1",
66-
"key2", NULL, NULL, NULL, NULL,
67-
#define URL_EMPTY_VALUE_END (URL_EMPTY_VALUE_START + 10)
66+
"key2", NULL, NULL, NULL, "",
67+
"key3", NULL, NULL, NULL, "",
68+
#define URL_EMPTY_VALUE_END (URL_EMPTY_VALUE_START + 15)
6869
NULL, NULL, NULL, NULL, NULL
6970
};
7071

@@ -95,8 +96,8 @@ value_checker (void *cls,
9596
"VC: `%s' `%s' `%s' `%s' `%.*s'\n",
9697
key, filename, content_type, transfer_encoding, size, data);
9798
#endif
98-
if (size == 0)
99-
return MHD_YES;
99+
if ( (0 != off) && (0 == size) )
100+
return MHD_YES;
100101
if ((idx < 0) ||
101102
(want[idx] == NULL) ||
102103
(0 != strcmp (key, want[idx])) ||

0 commit comments

Comments
 (0)