aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ypserv
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2011-12-21 20:27:41 +0000
committerEitan Adler <eadler@FreeBSD.org>2011-12-21 20:27:41 +0000
commit520374b5aacab7f83a72364ca0c8be1f439c7ced (patch)
tree7c566920fb5ced92e004cf337adc73daa4f7fdb7 /usr.sbin/ypserv
parentff0dd2e517a000de5707292356214a33bf35e680 (diff)
downloadsrc-520374b5aacab7f83a72364ca0c8be1f439c7ced.tar.gz
src-520374b5aacab7f83a72364ca0c8be1f439c7ced.zip
- Remove extraneous null ptr deref checks
- Fix memory leak Submitted by: Slono Slono <slonoman2011@yandex.ru> Approved by: jhb MFC after: 1 week
Notes
Notes: svn path=/head/; revision=228790
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r--usr.sbin/ypserv/yp_main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index 7473e6fc4396..6da1ea58d8e8 100644
--- a/usr.sbin/ypserv/yp_main.c
+++ b/usr.sbin/ypserv/yp_main.c
@@ -256,6 +256,7 @@ create_service(const int sock, const struct netconfig *nconf,
const struct __rpc_sockinfo *si)
{
int error;
+ char *sname;
SVCXPRT *transp;
struct addrinfo hints, *res, *res0;
@@ -263,6 +264,7 @@ create_service(const int sock, const struct netconfig *nconf,
struct bindaddrlistent *blep;
struct netbuf svcaddr;
+ sname = NULL;
SLIST_INIT(&sle_head);
memset(&hints, 0, sizeof(hints));
memset(&svcaddr, 0, sizeof(svcaddr));
@@ -342,7 +344,6 @@ create_service(const int sock, const struct netconfig *nconf,
if (strncmp("0", servname, 1) == 0) {
struct sockaddr *sap;
socklen_t slen;
- char *sname;
sname = malloc(NI_MAXSERV);
if (sname == NULL) {
@@ -362,6 +363,7 @@ create_service(const int sock, const struct netconfig *nconf,
strerror(errno));
freeaddrinfo(res0);
close(s);
+ free(sname);
return -1;
}
error = getnameinfo(sap, slen,
@@ -373,6 +375,7 @@ create_service(const int sock, const struct netconfig *nconf,
strerror(errno));
freeaddrinfo(res0);
close(s);
+ free(sname);
return -1;
}
servname = sname;
@@ -441,7 +444,7 @@ create_service(const int sock, const struct netconfig *nconf,
}
/* XXX: ignore error intentionally */
rpcb_set(YPPROG, YPVERS, nconf, &svcaddr);
-
+ free (sname);
freeaddrinfo(res0);
return 0;
}