changeset 4517:ae3b0ea6c309 draft

sa: Ensure sa_addrtop has a buffer to write to While here, if sa_family is AF_UNSPEC print a blank string.
author Roy Marples <roy@marples.name>
date Sun, 05 May 2019 12:46:32 +0100
parents a519e4e62efd
children e523b7420583
files src/sa.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/sa.c	Sun May 05 12:45:29 2019 +0100
+++ b/src/sa.c	Sun May 05 12:46:32 2019 +0100
@@ -364,6 +364,13 @@
 	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)