]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: sample: urlp can't match an empty value
authorCyril Bonté <cyril.bonte@free.fr>
Thu, 26 Nov 2015 20:39:56 +0000 (21:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Nov 2015 22:51:42 +0000 (23:51 +0100)
Currently urlp fetching samples were able to find parameters with an empty
value, but the return code depended on the value length. The final result was
that acls using urlp couldn't match empty values.

Example of acl which always returned "false":
  acl MATCH_EMPTY urlp(foo) -m len 0

The fix consists in unconditionally return 1 when the parameter is found.

This fix must be backported to 1.6 and 1.5.

src/proto_http.c

index 67e482fea7f3745a73230f42d30c74c46757b4d7..1d000717279fb8b9f8f83567bedf3fca34640f71 100644 (file)
@@ -11578,10 +11578,11 @@ find_url_param_pos(const char **chunks,
 }
 
 /*
- * Given a url parameter name and a query string, returns its value and size
- * into *value and *value_l respectively, and returns non-zero. An empty
- * url_param_name matches the first available parameter. If the parameter is
- * not found, zero is returned and value/value_l are not touched.
+ * Given a url parameter name and a query string, find the next value.
+ * An empty url_param_name matches the first available parameter.
+ * If the parameter is found, 1 is returned and *vstart / *vend are updated to
+ * respectively provide a pointer to the value and its end.
+ * Otherwise, 0 is returned and vstart/vend are not modified.
  */
 static int
 find_next_url_param(const char **chunks,
@@ -11660,7 +11661,7 @@ find_next_url_param(const char **chunks,
 
        *vstart = value_start;
        *vend = value_end;
-       return value_end != value_start;
+       return 1;
 }
 
 /* This scans a URL-encoded query string. It takes an optionally wrapping