diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2017-07-19 12:32:14 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2017-07-19 12:32:14 +0000 |
commit | 0445bd1870adf2b28e61d41f528db97514fb123d (patch) | |
tree | da9d221427af73a3ff1e4b7325b61eb1af236d3d /sys/nfs | |
parent | acb94aaceee3367457be65a9f03eb76ddc6e18f0 (diff) |
If second xdr_string_encode() fails in bp_getfile() m_freem() m since
this mbuf was allocated by the first call. Fixes possible memory leak.
Found by Ilja Van Sprundel
OK bluhm@ deraadt@
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_boot.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/nfs/nfs_boot.c b/sys/nfs/nfs_boot.c index f0bf6359b2f..814b7902c7b 100644 --- a/sys/nfs/nfs_boot.c +++ b/sys/nfs/nfs_boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_boot.c,v 1.41 2016/12/19 08:36:50 mpi Exp $ */ +/* $OpenBSD: nfs_boot.c,v 1.42 2017/07/19 12:32:13 claudio Exp $ */ /* $NetBSD: nfs_boot.c,v 1.26 1996/05/07 02:51:25 thorpej Exp $ */ /* @@ -453,8 +453,10 @@ bp_getfile(struct sockaddr_in *bpsin, char *key, struct sockaddr_in *md_sin, /* key name (root or swap) */ m->m_next = xdr_string_encode(key, strlen(key)); - if (m->m_next == NULL) + if (m->m_next == NULL) { + m_freem(m); return (ENOMEM); + } /* RPC: bootparam/getfile */ error = krpc_call(bpsin, BOOTPARAM_PROG, BOOTPARAM_VERS, |