diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2006-07-11 14:12:29 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2006-07-11 14:12:29 +0000 |
commit | be24d50c035f30e512f14a94651107aaecd31ceb (patch) | |
tree | 52cede32f62390036ac47bc25fa12093e00c6196 /strings | |
parent | 02115880b2a3ec29da470189e10dfd719b70a619 (diff) | |
download | libapr-be24d50c035f30e512f14a94651107aaecd31ceb.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: http://svn.apache.org/repos/asf/apr/apr/trunk@420858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r-- | strings/apr_snprintf.c | 4 |
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; } |