Fix: Unchecked asprintf/vasprintf return values
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 12 Jul 2013 16:38:56 +0000 (12:38 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 12 Jul 2013 18:12:33 +0000 (14:12 -0400)
strp may be modified even in case of failure according to the
ASPRINTF(3) man page.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/utils/tap/tap.c

index a430951193328aca551e34dfa1f3622a9b23ef28..5d64d844cbd3975ac7735e0fa75f837cf858ade1 100644 (file)
@@ -83,7 +83,9 @@ _gen_result(int ok, const char *func, char *file, unsigned int line,
           expansions on it */
        if(test_name != NULL) {
                va_start(ap, test_name);
-               vasprintf(&local_test_name, test_name, ap);
+               if (vasprintf(&local_test_name, test_name, ap) == -1) {
+                       local_test_name = NULL;
+               }
                va_end(ap);
 
                /* Make sure the test name contains more than digits
@@ -299,7 +301,9 @@ skip(unsigned int n, char *fmt, ...)
        LOCK;
 
        va_start(ap, fmt);
-       asprintf(&skip_msg, fmt, ap);
+       if (asprintf(&skip_msg, fmt, ap) == -1) {
+               skip_msg = NULL;
+       }
        va_end(ap);
 
        while(n-- > 0) {
@@ -324,7 +328,9 @@ todo_start(char *fmt, ...)
        LOCK;
 
        va_start(ap, fmt);
-       vasprintf(&todo_msg, fmt, ap);
+       if (vasprintf(&todo_msg, fmt, ap) == -1) {
+               todo_msg = NULL;
+       }
        va_end(ap);
 
        todo = 1;
This page took 0.026476 seconds and 4 git commands to generate.