summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-18 00:31:50 +0000
committerBruno Haible <bruno@clisp.org>2007-03-18 00:31:50 +0000
commitc114350b101f758aadbd236ae9ea4cb596b622fb (patch)
tree99593a869374d7a2f9de6bac21c1fbd54553f45f /lib/vsprintf.c
parent122d84991204bc27f91b2603ca1b3331310ee8cb (diff)
downloadgnulib-c114350b101f758aadbd236ae9ea4cb596b622fb.tar.gz
Fix endless loop when the given allocated size was > INT_MAX.
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d25c4a65f9..a9d840d9c8 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -46,7 +46,9 @@ vsprintf (char *str, const char *format, va_list args)
{
char *output;
size_t len;
- size_t lenbuf = SIZE_MAX;
+ /* vasnprintf fails with EOVERFLOW when the buffer size argument is larger
+ than INT_MAX (if that fits into a 'size_t' at all). */
+ size_t lenbuf = (SIZE_MAX < INT_MAX ? SIZE_MAX : INT_MAX);
output = vasnprintf (str, &lenbuf, format, args);
len = lenbuf;