From: Roy Marples Date: Sun, 5 May 2019 11:46:32 +0000 (+0100) Subject: sa: Ensure sa_addrtop has a buffer to write to X-Git-Tag: v8.0.0~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1ec97d0587776100fc4b4276b600f19e80cbc71;p=thirdparty%2Fdhcpcd.git sa: Ensure sa_addrtop has a buffer to write to While here, if sa_family is AF_UNSPEC print a blank string. --- diff --git a/src/sa.c b/src/sa.c index ca63493e..bc9f5d6c 100644 --- a/src/sa.c +++ b/src/sa.c @@ -364,6 +364,13 @@ sa_addrtop(const struct sockaddr *sa, char *buf, socklen_t len) const void *addr; assert(buf != NULL); + assert(len > 0); + + if (sa->sa_family == 0) { + *buf = '\0'; + return NULL; + } + #ifdef AF_LINK #ifndef CLLADDR #define CLLADDR(sdl) (const void *)((sdl)->sdl_data + (sdl)->sdl_nlen)