check strdup results too
include the function name in out of memory messages
This commit is contained in:
parent
05d4f66d89
commit
5794a3e6bf
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpcb_svc_com.c,v 1.21 2019/01/03 19:04:21 christos Exp $ */
|
||||
/* $NetBSD: rpcb_svc_com.c,v 1.22 2019/01/03 19:26:50 christos Exp $ */
|
||||
/* $FreeBSD: head/usr.sbin/rpcbind/rpcb_svc_com.c 301770 2016-06-09 22:25:00Z pfg $ */
|
||||
|
||||
/*-
|
||||
|
@ -306,8 +306,12 @@ delete_prog(rpcprog_t prog)
|
|||
reg.r_prog = rbl->rpcb_map.r_prog;
|
||||
reg.r_vers = rbl->rpcb_map.r_vers;
|
||||
reg.r_netid = strdup(rbl->rpcb_map.r_netid);
|
||||
(void)map_unset(®, rpcbind_superuser);
|
||||
free(reg.r_netid);
|
||||
if (reg.r_netid == NULL)
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
else {
|
||||
(void)map_unset(®, rpcbind_superuser);
|
||||
free(reg.r_netid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -508,16 +512,16 @@ create_rmtcall_fd(struct netconfig *nconf)
|
|||
nconf->nc_device, errno);
|
||||
return (-1);
|
||||
}
|
||||
xprt = svc_tli_create(fd, 0, (struct t_bind *) 0, 0, 0);
|
||||
xprt = svc_tli_create(fd, 0, NULL, 0, 0);
|
||||
if (xprt == NULL) {
|
||||
if (debugging)
|
||||
fprintf(stderr,
|
||||
"create_rmtcall_fd: svc_tli_create failed\n");
|
||||
"%s: svc_tli_create failed\n", __func__);
|
||||
return (-1);
|
||||
}
|
||||
rmt = malloc(sizeof(struct rmtcallfd_list));
|
||||
rmt = malloc(sizeof(*rmt));
|
||||
if (rmt == NULL) {
|
||||
syslog(LOG_ERR, "create_rmtcall_fd: no memory!");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
return (-1);
|
||||
}
|
||||
rmt->xprt = xprt;
|
||||
|
@ -813,9 +817,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|||
if (outbuf_alloc == NULL) {
|
||||
if (reply_type == RPCBPROC_INDIRECT)
|
||||
svcerr_systemerr(transp);
|
||||
if (debugging)
|
||||
fprintf(stderr,
|
||||
"rpcbproc_callit_com: No memory!\n");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
xdrmem_create(&outxdr, outbuf_alloc, sendsz, XDR_ENCODE);
|
||||
|
@ -1462,7 +1464,7 @@ add_pmaplist(RPCB *arg)
|
|||
*/
|
||||
pml = malloc(sizeof(*pml));
|
||||
if (pml == NULL) {
|
||||
(void) syslog(LOG_ERR, "rpcbind: no memory!\n");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
return (1);
|
||||
}
|
||||
pml->pml_map = pmap;
|
||||
|
@ -1474,7 +1476,7 @@ add_pmaplist(RPCB *arg)
|
|||
|
||||
/* Attach to the end of the list */
|
||||
for (fnd = list_pml; fnd->pml_next; fnd = fnd->pml_next)
|
||||
;
|
||||
continue;
|
||||
fnd->pml_next = pml;
|
||||
}
|
||||
return (0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpcbind.c,v 1.26 2019/01/03 19:04:21 christos Exp $ */
|
||||
/* $NetBSD: rpcbind.c,v 1.27 2019/01/03 19:26:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
|
@ -482,9 +482,8 @@ init_transport(struct netconfig *nconf)
|
|||
taddr.addr.len = taddr.addr.maxlen = addrlen;
|
||||
taddr.addr.buf = malloc(addrlen);
|
||||
if (taddr.addr.buf == NULL) {
|
||||
syslog(LOG_ERR,
|
||||
"cannot allocate memory for %s address",
|
||||
nconf->nc_netid);
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory",
|
||||
__func__);
|
||||
if (res != NULL)
|
||||
freeaddrinfo(res);
|
||||
return 1;
|
||||
|
@ -540,8 +539,7 @@ init_transport(struct netconfig *nconf)
|
|||
taddr.addr.len = taddr.addr.maxlen = addrlen;
|
||||
taddr.addr.buf = malloc(addrlen);
|
||||
if (taddr.addr.buf == NULL) {
|
||||
syslog(LOG_ERR, "cannot allocate memory for %s address",
|
||||
nconf->nc_netid);
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
if (res != NULL)
|
||||
freeaddrinfo(res);
|
||||
return 1;
|
||||
|
@ -567,7 +565,7 @@ init_transport(struct netconfig *nconf)
|
|||
|
||||
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
|
||||
RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
if (my_xprt == (SVCXPRT *)NULL) {
|
||||
if (my_xprt == NULL) {
|
||||
syslog(LOG_ERR, "%s: could not create service",
|
||||
nconf->nc_netid);
|
||||
goto error;
|
||||
|
@ -592,7 +590,7 @@ init_transport(struct netconfig *nconf)
|
|||
}
|
||||
pml = malloc(sizeof(*pml));
|
||||
if (pml == NULL) {
|
||||
syslog(LOG_ERR, "Cannot allocate memory");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -609,7 +607,8 @@ init_transport(struct netconfig *nconf)
|
|||
tcptrans = strdup(nconf->nc_netid);
|
||||
if (tcptrans == NULL) {
|
||||
free(pml);
|
||||
syslog(LOG_ERR, "Cannot allocate memory");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory",
|
||||
__func__);
|
||||
goto error;
|
||||
}
|
||||
pml->pml_map.pm_prot = IPPROTO_TCP;
|
||||
|
@ -627,7 +626,8 @@ init_transport(struct netconfig *nconf)
|
|||
udptrans = strdup(nconf->nc_netid);
|
||||
if (udptrans == NULL) {
|
||||
free(pml);
|
||||
syslog(LOG_ERR, "Cannot allocate memory");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory",
|
||||
__func__);
|
||||
goto error;
|
||||
}
|
||||
pml->pml_map.pm_prot = IPPROTO_UDP;
|
||||
|
@ -646,7 +646,7 @@ init_transport(struct netconfig *nconf)
|
|||
/* Add version 3 information */
|
||||
pml = malloc(sizeof(*pml));
|
||||
if (pml == NULL) {
|
||||
syslog(LOG_ERR, "Cannot allocate memory");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
pml->pml_map = list_pml->pml_map;
|
||||
|
@ -657,7 +657,7 @@ init_transport(struct netconfig *nconf)
|
|||
/* Add version 4 information */
|
||||
pml = malloc(sizeof(*pml));
|
||||
if (pml == NULL) {
|
||||
syslog(LOG_ERR, "Cannot allocate memory");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
pml->pml_map = list_pml->pml_map;
|
||||
|
@ -812,9 +812,9 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
|
|||
{
|
||||
rpcblist_ptr rbl;
|
||||
|
||||
rbl = malloc(sizeof(*rbl));
|
||||
rbl = calloc(1, sizeof(*rbl));
|
||||
if (rbl == NULL) {
|
||||
syslog(LOG_ERR, "Out of memory");
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -823,6 +823,17 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
|
|||
rbl->rpcb_map.r_netid = strdup(nconf->nc_netid);
|
||||
rbl->rpcb_map.r_addr = taddr2uaddr(nconf, addr);
|
||||
rbl->rpcb_map.r_owner = strdup(rpcbind_superuser);
|
||||
if (rbl->rpcb_map.r_netid == NULL ||
|
||||
rbl->rpcb_map.r_addr == NULL ||
|
||||
rbl->rpcb_map.r_owner == NULL)
|
||||
{
|
||||
free(rbl->rpcb_map.r_netid);
|
||||
free(rbl->rpcb_map.r_addr);
|
||||
free(rbl->rpcb_map.r_owner);
|
||||
free(rbl);
|
||||
syslog(LOG_ERR, "%s: Cannot allocate memory", __func__);
|
||||
return;
|
||||
}
|
||||
rbl->rpcb_next = list_rbl; /* Attach to global list */
|
||||
list_rbl = rbl;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue