INN commit: trunk/lib (asprintf.c)
rra at isc.org
Sun Nov 3 19:16:22 UTC 2013
Date: Sunday, November 3, 2013 @ 11:16:22
asprintf.c: synchronize with rra-c-util
In the vasprintf replacement, preserve errno if snprintf fails when
formatting the string into the newly-allocated buffer.
asprintf.c | 44 +++++++++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 13 deletions(-)
--- asprintf.c 2013-11-03 19:11:51 UTC (rev 9552)
+++ asprintf.c 2013-11-03 19:16:22 UTC (rev 9553)
@@ -1,19 +1,33 @@
-** Replacement for a missing asprintf and vasprintf.
-** Written by Russ Allbery <rra at stanford.edu>
-** This work is hereby placed in the public domain by its author.
-** Provides the same functionality as the standard GNU library routines
-** asprintf and vasprintf for those platforms that don't have them.
+ * Replacement for a missing asprintf and vasprintf.
+ * Provides the same functionality as the standard GNU library routines
+ * asprintf and vasprintf for those platforms that don't have them.
+ * The canonical version of this file is maintained in the rra-c-util package,
+ * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * Written by Russ Allbery <rra at stanford.edu>
+ * The authors hereby relinquish any claim to any copyright that they may have
+ * in this work, whether granted under contract or by operation of law or
+ * international treaty, and hereby commit to the public, at large, that they
+ * shall not, at any time in the future, seek to enforce any copyright in this
+ * work against any person or entity, or prevent any person or entity from
+ * copying, publishing, distributing or creating derivative works of this
+ * work.
-/* If we're running the test suite, rename the functions to avoid conflicts
- with the system versions. */
+ * If we're running the test suite, rename the functions to avoid conflicts
+ * with the system versions.
# define asprintf test_asprintf
# define vasprintf test_vasprintf
@@ -22,6 +36,7 @@
int test_vasprintf(char **, const char *, va_list);
asprintf(char **strp, const char *fmt, ...)
@@ -34,11 +49,12 @@
vasprintf(char **strp, const char *fmt, va_list args)
- int status, needed;
+ int status, needed, oerrno;
needed = vsnprintf(NULL, 0, fmt, args_copy);
@@ -54,8 +70,10 @@
if (status >= 0)
+ oerrno = errno;
*strp = NULL;
+ errno = oerrno;
More information about the inn-committers