[hackers] [quark] sanity check || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Sat, 15 Aug 2009 21:59:42 +0000 (UTC)

changeset: 6:5f54ef77f469
tag: tip
user: Anselm R Garbe <anselm_AT_garbe.us>
date: Sat Aug 15 22:59:41 2009 +0100
files: quark.c
description:
sanity check

diff -r ee69b12aece3 -r 5f54ef77f469 quark.c
--- a/quark.c Sat Aug 15 22:37:29 2009 +0100
+++ b/quark.c Sat Aug 15 22:59:41 2009 +0100
@@ -279,22 +279,21 @@
         for(p = reqbuf; p < reqbuf + MAXREQLEN && *p != '\r' && *p != '\n'; p++);
         if(*p == '\r' || *p == '\n') {
                 *p = 0;
- /* parse command */
- if(strncmp(reqbuf, "GET ", 4)) {
- fprintf(stderr, "%s: %s performs unsupported request %s\n", tstamp(), name, reqbuf);
- return -1;
- }
- if(reqbuf[4] != '/') {
- fprintf(stderr, "%s: %s performs invalid request %s\n", tstamp(), name, reqbuf);
- return -1;
- }
+ /* check command */
+ if(strncmp(reqbuf, "GET ", 4) || reqbuf[4] != '/')
+ goto invalid_request;
         }
+ else
+ goto invalid_request;
         /* determine path */
         for(res = reqbuf + 4; *res && *(res + 1) == '/'; res++);
         for(p = res; *p && *p != ' '; p++);
         *p = 0;
         memmove(reqbuf, res, (p - res) + 1);
         return 0;
+invalid_request:
+ fprintf(stderr, "%s: %s performs invalid request %s\n", tstamp(), name, reqbuf);
+ return -1;
 }
 
 void
Received on Sat Aug 15 2009 - 21:59:42 UTC

This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:19:07 UTC