From: Eric Bollengier Date: Thu, 14 Jul 2016 11:43:57 +0000 (+0200) Subject: Handle NULL pointers in smartdump() and asciidump() X-Git-Tag: Release-7.4.4~9 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=06237444ab0d2a098b5a0697b1d092d23bf80f43;p=bacula%2Fbacula Handle NULL pointers in smartdump() and asciidump() --- 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; }