From 06237444ab0d2a098b5a0697b1d092d23bf80f43 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 14 Jul 2016 13:43:57 +0200 Subject: [PATCH] Handle NULL pointers in smartdump() and asciidump() --- bacula/src/lib/util.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 4456c80a25..88de1b0cac 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -199,6 +199,10 @@ char *asciidump(const char *data, int len, char *buf, int capacity) { char *b=buf; const unsigned char *p=(const unsigned char *)data; + if (!data) { + strncpy(buf, "", capacity); + return buf; + } while (len>0 && capacity>1) { if (isprint(*p)) { *(b++)=*(p++); @@ -223,6 +227,10 @@ char *smartdump(const char *data, int len, char *buf, int capacity, bool *is_asc int l=len; int c=capacity; const unsigned char *p=(const unsigned char *)data; + if (!data) { + strncpy(buf, "", capacity); + return buf; + } if (is_ascii != NULL) { *is_ascii = false; } -- 2.39.5