From 4a81005f234436f91620fb43d5543912625544cb Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 28 Apr 2010 06:39:22 +0000 Subject: [PATCH 1/1] fxed bug #17169 wrong return value of HttpMessage::getHttpVersion() --- http_message_object.c | 14 +++++++------- package.xml | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/http_message_object.c b/http_message_object.c index 6732059..60fd8df 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -1100,11 +1100,11 @@ PHP_METHOD(HttpMessage, getHttpVersion) NO_ARGS; if (return_value_used) { - char ver[4] = {0}; + char *version; getObject(http_message_object, obj); - sprintf(ver, "%1.1lf", obj->message->http.version); - RETURN_STRINGL(ver, 3, 1); + spprintf(&version, 0, "%1.1F", obj->message->http.version); + RETURN_STRING(version, 0); } } /* }}} */ @@ -1113,8 +1113,8 @@ PHP_METHOD(HttpMessage, getHttpVersion) Set the HTTP Protocol version of the Message. */ PHP_METHOD(HttpMessage, setHttpVersion) { - char v[4]; zval *zv; + char *version; getObject(http_message_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &zv)) { @@ -1122,9 +1122,9 @@ PHP_METHOD(HttpMessage, setHttpVersion) } convert_to_double(zv); - snprintf(v, sizeof(v), "%1.1f", Z_DVAL_P(zv)); - if (strcmp(v, "1.0") && strcmp(v, "1.1")) { - http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid HTTP protocol version (1.0 or 1.1): %g", Z_DVAL_P(zv)); + spprintf(&version, 0, "%1.1F", Z_DVAL_P(zv)); + if (strcmp(version, "1.0") && strcmp(version, "1.1")) { + http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid HTTP protocol version (1.0 or 1.1): %s", version); RETURN_FALSE; } diff --git a/package.xml b/package.xml index bb75602..06dc8fd 100644 --- a/package.xml +++ b/package.xml @@ -52,7 +52,8 @@ support. Parallel requests are available for PHP 5 and greater. - HTTP_PROXY_HTTP_1_0 * Added request info members: - condition_unmet (libcurl >= 7.19.4) -* Fixed bug #17087 http_build_cookie() exhausts memory if cookie value is NULL +* Fixed bug #17087 (http_build_cookie() exhausts memory if cookie value is NULL) +* Fixed bug #17169 (Wrong return value of HttpMessage::getHttpVersion()) ]]> -- 2.30.2