From: Joe Orton Date: Thu, 23 Sep 2004 18:18:36 +0000 (+0000) Subject: Backport from HEAD: X-Git-Tag: 2.0.53~264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b59f452e9229ce8f24dab9c9abd93bc9387e650;p=thirdparty%2Fapache%2Fhttpd.git Backport from HEAD: * server/protocol.c (ap_rgetline_core): Never NUL terminate at (*s)[-1] for caller-supplied *s. Submitted by: Rici Lake Reviewed by: jorton, jerenkrantz, trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@105278 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/protocol.c b/server/protocol.c index 028bcb9beee..5d80a445a3f 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -251,12 +251,12 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, if (n < bytes_handled + len) { *read = bytes_handled; if (*s) { - /* ensure this string is terminated */ - if (bytes_handled < n) { + /* ensure this string is NUL terminated */ + if (bytes_handled > 0) { (*s)[bytes_handled-1] = '\0'; } else { - (*s)[n-1] = '\0'; + (*s)[0] = '\0'; } } return APR_ENOSPC;