summaryrefslogtreecommitdiff
path: root/strings/apr_snprintf.c
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2006-07-11 14:12:29 +0000
committerJoe Orton <jorton@apache.org>2006-07-11 14:12:29 +0000
commit52a98cc84e2e62638f712b3bedf20873150de21e (patch)
tree52cede32f62390036ac47bc25fa12093e00c6196 /strings/apr_snprintf.c
parent7c40ead74cf9bef4f09959ccd9cbf79278c29c3d (diff)
downloadapr-52a98cc84e2e62638f712b3bedf20873150de21e.tar.gz
* strings/apr_snprintf.c (apr_snprintf, apr_vsnprintf): Fix to
returning number of bytes *without* NUL in overflow case. * test/teststr.c (snprintf_overflow): New test case. PR: 39996 Submitted by: Michal Luczaj <regenrecht o2.pl> git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@420858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings/apr_snprintf.c')
-rw-r--r--strings/apr_snprintf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/strings/apr_snprintf.c b/strings/apr_snprintf.c
index 0cfdad1f4..c0510a38b 100644
--- a/strings/apr_snprintf.c
+++ b/strings/apr_snprintf.c
@@ -1360,7 +1360,7 @@ APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len,
if (len != 0) {
*vbuff.curpos = '\0';
}
- return (cc == -1) ? (int)len : cc;
+ return (cc == -1) ? (int)len - 1 : cc;
}
@@ -1383,5 +1383,5 @@ APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format,
if (len != 0) {
*vbuff.curpos = '\0';
}
- return (cc == -1) ? (int)len : cc;
+ return (cc == -1) ? (int)len - 1 : cc;
}