summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorGreg Ames <gregames@apache.org>2004-04-23 00:38:03 +0200
committerGreg Ames <gregames@apache.org>2004-04-23 00:38:03 +0200
commite9b7d5fefe82fef8afb9e12094d5cf8426e514bb (patch)
tree9a9eb5b1c36668861fd1f4cbbfc36f199a0add84 /server
parentdeclare the prototypes as well. (diff)
downloadapache2-e9b7d5fefe82fef8afb9e12094d5cf8426e514bb.tar.xz
apache2-e9b7d5fefe82fef8afb9e12094d5cf8426e514bb.zip
ap_rgetline_core: insure that the output string is null terminated
when exiting with APR_ENOSPC Submitted by: Tsurutani Naoki <turutani scphys.kyoto-u.ac.jp> git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103482 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/protocol.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/protocol.c b/server/protocol.c
index 60203064b0..fb53fadb63 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -251,6 +251,15 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
/* Would this overrun our buffer? If so, we'll die. */
if (n < bytes_handled + len) {
*read = bytes_handled;
+ if (*s) {
+ /* ensure this string is terminated */
+ if (bytes_handled < n) {
+ (*s)[bytes_handled] = '\0';
+ }
+ else {
+ (*s)[n-1] = '\0';
+ }
+ }
return APR_ENOSPC;
}
@@ -379,6 +388,8 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
/* Do we have enough space? We may be full now. */
if (bytes_handled >= n) {
*read = n;
+ /* ensure this string is terminated */
+ (*s)[n-1] = '\0';
return APR_ENOSPC;
}
else {