Skip to content

Commit

Permalink
Be tolerant of lower-case HTTP requests. Prevent SEGV.
Browse files Browse the repository at this point in the history
Issue found by Jean-Denis Girard.
  • Loading branch information
davies147 committed Dec 8, 2008
1 parent 974c824 commit f4b952a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ int _read(struct mansession *s, struct message *m) {
/* No HTTP Input may be longer than BUFSIZE */

char line[MAX_LEN], method[10], formdata[MAX_LEN], status[15];
char *tmp;
int res, clength = 0;

memset(method, 0, sizeof method);
Expand Down Expand Up @@ -190,14 +191,14 @@ int _read(struct mansession *s, struct message *m) {
if ( !strncmp(line,"POST",4) ) {
strncpy(method, line, 4);
} else if ( !strncmp(line,"GET",3)) {
if ( strlen(line) > 14 ) {
/* GET / HTTP/1.1 ---- this is bad */
if ( strlen(line) > 14 && (tmp = strcasestr(line, " HTTP")) ) {
/* GET / HTTP/1.1 ---- this is bad */
/* GET /?Action=Ping&ActionID=Foo HTTP/1.1 */
strncpy(method, line, 3);
memcpy(formdata, line+6, strstr(line, " HTTP")-line-6);
sprintf(status, "200 OK");
} else
sprintf(status, "501 Not Implemented");
memcpy(formdata, line+6, tmp-line-6);
sprintf(status, "200 OK");
} else
sprintf(status, "501 Not Implemented");
}
}
} else if (res == 0) {
Expand Down

0 comments on commit f4b952a

Please sign in to comment.