summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-03-22 13:39:20 +0100
committerGergely Nagy <algernon@balabit.hu>2012-03-22 13:39:20 +0100
commit1c3b587b949bbaa19010fb4530282417015df4b6 (patch)
tree2c47c8dbff1a039eb381e383b423674f6ab5cbb7
parentbb11776e30a9f97ca807aa38a6eeeba5a7192f44 (diff)
Check (v)asprintf() return values.
If (v)asprintf() returns an error, abort() away, because we can't possibly proceed. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
-rw-r--r--lib/cee-syslog.c6
-rw-r--r--t/test_cee_format.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/cee-syslog.c b/lib/cee-syslog.c
index d6ae7fc..2cb5447 100644
--- a/lib/cee-syslog.c
+++ b/lib/cee-syslog.c
@@ -160,7 +160,8 @@ _cee_json_vappend (struct json_object *json, va_list ap)
char *fmt = (char *)va_arg (ap, char *);
char *value;
- vasprintf (&value, fmt, ap);
+ if (vasprintf (&value, fmt, ap) == -1)
+ abort ();
json_object_object_add (json, key, json_object_new_string (value));
free (value);
}
@@ -227,7 +228,8 @@ _cee_vformat (struct json_object *jo, int format_version,
{
char *value;
- vasprintf (&value, msg_format, ap);
+ if (vasprintf (&value, msg_format, ap) == -1)
+ abort ();
json_object_object_add (jo, "msg", json_object_new_string (value));
free (value);
diff --git a/t/test_cee_format.c b/t/test_cee_format.c
index ec48603..1d3a7a0 100644
--- a/t/test_cee_format.c
+++ b/t/test_cee_format.c
@@ -153,7 +153,8 @@ test_discover_priority (void)
verify_value (jo, "msg", "testing 1, 2, 3...");
- asprintf (&pid, "%d", getpid ());
+ if (asprintf (&pid, "%d", getpid ()) == -1)
+ abort ();
verify_value (jo, "pid", pid);
free (pid);