sanity check
This commit is contained in:
parent
4b8f562095
commit
15edad07bb
1 changed files with 8 additions and 9 deletions
17
quark.c
17
quark.c
|
@ -279,22 +279,21 @@ request(void) {
|
||||||
for(p = reqbuf; p < reqbuf + MAXREQLEN && *p != '\r' && *p != '\n'; p++);
|
for(p = reqbuf; p < reqbuf + MAXREQLEN && *p != '\r' && *p != '\n'; p++);
|
||||||
if(*p == '\r' || *p == '\n') {
|
if(*p == '\r' || *p == '\n') {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
/* parse command */
|
/* check command */
|
||||||
if(strncmp(reqbuf, "GET ", 4)) {
|
if(strncmp(reqbuf, "GET ", 4) || reqbuf[4] != '/')
|
||||||
fprintf(stderr, "%s: %s performs unsupported request %s\n", tstamp(), name, reqbuf);
|
goto invalid_request;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(reqbuf[4] != '/') {
|
|
||||||
fprintf(stderr, "%s: %s performs invalid request %s\n", tstamp(), name, reqbuf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
goto invalid_request;
|
||||||
/* determine path */
|
/* determine path */
|
||||||
for(res = reqbuf + 4; *res && *(res + 1) == '/'; res++);
|
for(res = reqbuf + 4; *res && *(res + 1) == '/'; res++);
|
||||||
for(p = res; *p && *p != ' '; p++);
|
for(p = res; *p && *p != ' '; p++);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
memmove(reqbuf, res, (p - res) + 1);
|
memmove(reqbuf, res, (p - res) + 1);
|
||||||
return 0;
|
return 0;
|
||||||
|
invalid_request:
|
||||||
|
fprintf(stderr, "%s: %s performs invalid request %s\n", tstamp(), name, reqbuf);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue