From: Michael Wallner Date: Sun, 2 Apr 2006 21:51:01 +0000 (+0000) Subject: - Disallow $HttpMessage->prepend($HttpMessage) causing infinite recursion X-Git-Tag: RELEASE_1_0_0RC3~20 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b0719c36a9a5340adb9a7cbabe0b486b215dee1f;p=m6w6%2Fext-http - Disallow $HttpMessage->prepend($HttpMessage) causing infinite recursion --- diff --git a/http_message_object.c b/http_message_object.c index 7069e6a..a04438b 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -1417,6 +1417,8 @@ PHP_METHOD(HttpMessage, detach) * Prepends message(s) to the HTTP message. * * Expects an HttpMessage object as parameter. + * + * Throws HttpInvalidParamException if the messages are located within the same message chain. */ PHP_METHOD(HttpMessage, prepend) { @@ -1424,6 +1426,20 @@ PHP_METHOD(HttpMessage, prepend) zend_bool top = 1; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &prepend, http_message_object_ce, &top)) { + http_message *msg[2]; + getObject(http_message_object, obj); + getObjectEx(http_message_object, prepend_obj, prepend); + + /* safety check */ + for (msg[0] = obj->message; msg[0]; msg[0] = msg[0]->parent) { + for (msg[1] = prepend_obj->message; msg[1]; msg[1] = msg[1]->parent) { + if (msg[0] == msg[1]) { + http_error(HE_THROW, HTTP_E_INVALID_PARAM, "Cannot prepend a message located within the same message chain"); + return; + } + } + } + http_message_object_prepend_ex(getThis(), prepend, top); } } diff --git a/package2.xml b/package2.xml index 84a78d8..892f1c8 100644 --- a/package2.xml +++ b/package2.xml @@ -47,6 +47,7 @@ HttpResponse BSD, revised prepend($HttpMessage) causing infinite recursion * Fixed internal http_parse_headers() always returning success * Fixed missing "parentMessage" entry in print_r($HttpMessageObject) ]]>