Hi, squid developers

When reading squid-2.6-STABLE15 source code, I found a logical error in
the "if" statement at "src/HttpHdrRange.c" line 96:     

        if (!((p = strchr(field, '-')) || (p - field >= flen))) {

If p is NULL, (p - field) is meaningless. If p is not NULL, the latter 
expression
won't be evaluated.

The statement should really be:

        if (!((p = strchr(field, '-')) && (p - field < flen))) {

Attaching a diff which fixes the logical error.

Wenzhuo
--- src/HttpHdrRange.c.original	2006-04-28 18:17:18.000000000 +0800
+++ src/HttpHdrRange.c	2007-09-06 16:36:17.000000000 +0800
@@ -93,7 +93,7 @@
 	    return NULL;
     } else
 	/* must have a '-' somewhere in _this_ field */
-    if (!((p = strchr(field, '-')) || (p - field >= flen))) {
+    if (!((p = strchr(field, '-')) && (p - field < flen))) {
 	debug(64, 2) ("ignoring invalid (missing '-') range-spec near: '%s'\n", field);
 	return NULL;
     } else {

Reply via email to