From: Joe Orton Date: Tue, 21 Sep 2004 21:07:23 +0000 (+0000) Subject: * server/protocol.c (ap_rgetline_core): Never NUL terminate at X-Git-Tag: 2.1.1~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b26d10798e3218c819fdd8cceaca4d43854c39c;p=thirdparty%2Fapache%2Fhttpd.git * server/protocol.c (ap_rgetline_core): Never NUL terminate at (*s)[-1] for caller-supplied *s. Submitted by: Rici Lake git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105231 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/protocol.c b/server/protocol.c index d3576c14054..81904a40a5e 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -252,12 +252,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;