[PATCH]: Sending HTTP_BAD_REQUEST to client in case of bad request

"Dziugas Baltrunas" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi list,

in case of client sends us malformed URL (such as 
/cgi-bin/sendsms?user=test&pass=test&to=12345 &text=test), attached
patch sends a HTTP 400 Bad request error instead of simply closing the
socket thus giving no indication to the client.

--
Dziugas
http_bad_request.patch (text/plain, 719 B)
Index: gwlib/http.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/http.c,v
retrieving revision 1.240
diff -u -r1.240 http.c
--- gwlib/http.c	5 Mar 2006 14:37:26 -0000	1.240
+++ gwlib/http.c	22 Mar 2006 11:03:25 -0000
@@ -2097,8 +2097,10 @@
 	    ret = parse_request_line(&client->method, &client->url,
                                      &client->use_version_1_0, line);
 	    octstr_destroy(line);
-	    if (ret == -1)
-	    	goto error;
+	    if (ret == -1) {
+		http_send_reply(client, HTTP_BAD_REQUEST, NULL, NULL);
+		goto error;
+	    }
    	    /*
 	     * RFC2616 (4.3) says we should read a message body if there
 	     * is one, even on GET requests.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.