From: Jérémie Galarneau Date: Fri, 12 Jul 2013 17:09:51 +0000 (-0400) Subject: Fix: Unchecked asprintf/vasprintf return values X-Git-Tag: v2.3.0-rc1~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=08fc51bdb83e1d05b7ce5cb71c1efcd39eaaacc4;p=lttng-ust.git Fix: Unchecked asprintf/vasprintf return values strp·may·be·modified·even·in·case·of·failure·according·to·the ASPRINTF(3) man page. Signed-off-by: Jérémie Galarneau Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/tap.c b/tests/tap.c index 86c89a23..8bf72f6f 100644 --- a/tests/tap.c +++ b/tests/tap.c @@ -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;