From: Ian Jackson Date: Thu, 5 Dec 2019 02:15:45 +0000 (+0000) Subject: stest/udp-preload.c: Fix error handling of sun_prep X-Git-Tag: v0.6.0~263 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a3e4fa1e50f925d776a8511902ad848874bb1fc5;p=secnet.git stest/udp-preload.c: Fix error handling of sun_prep If sun_prep returned an error (eg, path too long), this would segfault. Signed-off-by: Ian Jackson --- diff --git a/stest/udp-preload.c b/stest/udp-preload.c index 688df97..1f3e7e3 100644 --- a/stest/udp-preload.c +++ b/stest/udp-preload.c @@ -216,6 +216,7 @@ WRAP(bind) { if (!ent) return old_bind(fd,addr,addrlen); struct sockaddr_un sun; char *p=sun_prep(&sun); + if (!p) return -1; if (addrport2str(p,addr,addrlen)) return -1; //fprintf(stderr,"binding %s\n",sun.sun_path); if (unlink(sun.sun_path) && errno!=ENOENT) return -1; @@ -262,6 +263,7 @@ ssize_t TWRAP(sendto) { if (strlen(leaf) > ADDRPORTSTRLEN) { errno=ENAMETOOLONG; return -1; } struct sockaddr_un sun; char *p=sun_prep(&sun); + if (!p) return -1; strcpy(p,leaf); char tbuf[ADDRPORTSTRLEN+1];