shithub: sox

Download patch

ref: 0c5bf006be3ee062f0e551d0317dc06b0f2665ea
parent: a043cf72d4c034c7a6b8bfd94e6e22588d952281
author: rrt <rrt>
date: Sat Nov 25 19:10:43 EST 2006

Use vsnprintf for st_fail_errno. It's in C99, it should be in most
compilers by now. If we find one in which it doesn't work I'll add a
vasprintf implementation instead (I have one already).

--- a/src/util.c
+++ b/src/util.c
@@ -19,11 +19,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#ifdef __STDC__
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
 struct st_output_message_s
 {
@@ -122,12 +118,6 @@
 
 #undef ST_MESSAGE_FUNCTION
 
-
-
-/* Warning: no error checking is done with errstr.  Be sure not to
- * go over the array limit ourself!  vsnprint does not seem to be
- * on all platforms so not using that.
- */
 void st_fail_errno(ft_t ft, int st_errno, const char *fmt, ...)
 {
         va_list args;
@@ -135,7 +125,7 @@
         ft->st_errno = st_errno;
 
         va_start(args, fmt);
-        vsprintf(ft->st_errstr, fmt, args);
+        vsnprintf(ft->st_errstr, sizeof(ft->st_errstr), fmt, args);
         va_end(args);
         ft->st_errstr[255] = '\0';
 }