[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] cvs: pecl /http http_api.c
From:       "Michael Wallner" <mike () php ! net>
Date:       2006-12-19 14:26:47
Message-ID: cvsmike1166538407 () cvsserver
[Download RAW message or body]

mike		Tue Dec 19 14:26:47 2006 UTC

  Modified files:              
    /pecl/http	http_api.c 
  Log:
  - fix infinite loop with http_parse_params("=")
  
http://cvs.php.net/viewvc.cgi/pecl/http/http_api.c?r1=1.161&r2=1.162&diff_format=u
Index: pecl/http/http_api.c
diff -u pecl/http/http_api.c:1.161 pecl/http/http_api.c:1.162
--- pecl/http/http_api.c:1.161	Thu Nov 23 15:33:43 2006
+++ pecl/http/http_api.c	Tue Dec 19 14:26:47 2006
@@ -10,7 +10,7 @@
     +--------------------------------------------------------------------+
 */
 
-/* $Id: http_api.c,v 1.161 2006/11/23 15:33:43 mike Exp $ */
+/* $Id: http_api.c,v 1.162 2006/12/19 14:26:47 mike Exp $ */
 
 #define HTTP_WANT_SAPI
 #include "php_http.h"
@@ -411,9 +411,13 @@
 		if (vallen) {
 			MAKE_STD_ZVAL(entry);
 			array_init(entry);
-			kdup = estrndup(key, keylen);
-			add_assoc_stringl_ex(entry, kdup, keylen + 1, (char *) val, vallen, 1);
-			efree(kdup);
+			if (keylen) {
+				kdup = estrndup(key, keylen);
+				add_assoc_stringl_ex(entry, kdup, keylen + 1, (char *) val, vallen, 1);
+				efree(kdup);
+			} else {
+				add_next_index_stringl(entry, (char *) val, vallen, 1);
+			}
 			add_next_index_zval(&tmp, entry);
 		} else {
 			add_next_index_stringl(&tmp, (char *) key, keylen, 1);
@@ -435,7 +439,9 @@
 	char *s, *c, *key = NULL, *val = NULL;
 	
 	for(c = s = estrdup(param);;) {
+	continued:
 #if 0
+	{
 		char *tk = NULL, *tv = NULL;
 		
 		if (key) {
@@ -467,8 +473,8 @@
 				), *c?*c:'0', tk, tv
 		);
 		STR_FREE(tk); STR_FREE(tv);
+	}
 #endif
-	continued:
 		switch (st) {
 			case ST_QUOTE:
 			quote:
@@ -610,7 +616,15 @@
 		http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Unexpected character (%c) at pos \
%tu of %zu", *c, c-s, strlen(s));  }
 	if (flags & HTTP_PARAMS_ALLOW_FAILURE) {
-		--c;
+		if (st == ST_KEY) {
+			if (key) {
+				keylen = c - key;
+			} else {
+				key = c;
+			}
+		} else {
+			--c;
+		}
 		st = ST_ADD;
 		goto continued;
 	}

-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic