fxed bug #17169 wrong return value of HttpMessage::getHttpVersion()
authorMichael Wallner <mike@php.net>
Wed, 28 Apr 2010 06:39:22 +0000 (06:39 +0000)
committerMichael Wallner <mike@php.net>
Wed, 28 Apr 2010 06:39:22 +0000 (06:39 +0000)
http_message_object.c
package.xml

index 6732059c8a8e8ad01fbf9c9ac06f4eabbaed0131..60fd8dfafddf2e9ef971381fa727c16d28e375ab 100644 (file)
@@ -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;
        }
 
index bb75602e214191ec6f7ecdc72c3f5fcf04c94c9f..06dc8fd65fb88bd347a49845228b91383153c7fd 100644 (file)
@@ -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())
 ]]></notes>
  <contents>
   <dir name="/">