JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.91k stars 386 forks source link

POSTing XML input confuses siege #162

Open petriborg opened 4 years ago

petriborg commented 4 years ago

Any XML POST inputs will confuse siege. Example: siege -c 1 -r 1 -g "http://testsrv/ POST <?xml version='1.0' encoding='UTF-8'?><foobar/>"

This happens because siege will only look at the '<' character, and try to process the rest of the line as a filename. Issue is in ./src/url.c __parse_post_data(URL this, char *datap).

The following can help fix the issue by looking for the XML declaration.

diff --git a/src/url.c b/src/url.c
index 9297376..b9e83c3 100644
--- a/src/url.c
+++ b/src/url.c
@@ -643,7 +643,7 @@ __parse_post_data(URL this, char *datap)
   for (; isspace((unsigned int)*datap); datap++) {
     /* Advance past white space */
   }
-  if (*datap == '<') {
+  if (*datap == '<' && *(datap+1) != '?') {
     datap++;
     load_file(this, datap);
     datap = __url_set_path(this, datap);