]> granicus.if.org Git - php/commit
Change the search in get_status_string() to correctly handle unknown codes.
authorAdam Harvey <aharvey@php.net>
Wed, 19 Jun 2013 18:32:37 +0000 (11:32 -0700)
committerAdam Harvey <aharvey@php.net>
Thu, 20 Jun 2013 16:31:57 +0000 (09:31 -0700)
commit283f56af6696f57400bdbf8ce29ee66e64249c0d
tree070d31310cb4aea0105be3f7987e63a48e90738f
parentb5978e239ee308e425843e40eb6ab2a9f0beba83
Change the search in get_status_string() to correctly handle unknown codes.

This previously used a buggy implementation of binary search that would loop
infinitely for unknown codes when searching in reason arrays of particular
sizes (such as the one we have at the moment). Since C provides bsearch(),
we'll just use that instead, since libc authors hopefully get this right.

There was also an additional bug that was masked by the first one: the design
was that an unknown code would result in get_status_string() returning NULL,
which would then result in a segfault in append_http_status_line(), since it
assumed that it would always receive a valid string pointer that could be
handed off to smart_str_appends_ex(). We'll now return a placeholder in that
case.

Fixes bug #65066 (Cli server not responsive when responding with 422 http
status code).
NEWS
sapi/cli/php_cli_server.c
sapi/cli/tests/bug65066_100.phpt [new file with mode: 0644]
sapi/cli/tests/bug65066_422.phpt [new file with mode: 0644]
sapi/cli/tests/bug65066_511.phpt [new file with mode: 0644]