The following commit has been merged in the master branch:
commit 37c754ec3d45a121aeffc9c03dba8b97b1780f40
Author: Guillem Jover <[email protected]>
Date: Wed Oct 14 05:37:43 2009 +0200
libcompat: Handle 0 size case for C99 vsnprintf semantics
Reporter-by: Mikhail Gusarov <[email protected]>
diff --git a/lib/compat/vsnprintf.c b/lib/compat/vsnprintf.c
index ab52af8..72e88d8 100644
--- a/lib/compat/vsnprintf.c
+++ b/lib/compat/vsnprintf.c
@@ -2,6 +2,7 @@
* libcompat - system compatibility library
*
* Copyright © 1995 Ian Jackson <[email protected]>
+ * Copyright © 2008, 2009 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -33,7 +34,7 @@ vsnprintf(char *buf, size_t maxsize, const char *fmt, va_list
al)
size_t want, nr;
int total;
- if (maxsize == 0)
+ if (maxsize != 0 && buf == NULL)
return -1;
if (!file) {
@@ -50,6 +51,8 @@ vsnprintf(char *buf, size_t maxsize, const char *fmt, va_list
al)
total = vfprintf(file, fmt, al);
if (total < 0)
return -1;
+ if (maxsize == 0)
+ return total;
if (total >= (int)maxsize)
want = maxsize - 1;
else
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]