svn commit: r292636 - user/ngie/stable-10-libnv/lib/libnv

Garrett Cooper ngie at FreeBSD.org
Tue Dec 22 23:11:50 UTC 2015


Author: ngie
Date: Tue Dec 22 23:11:49 2015
New Revision: 292636
URL: https://svnweb.freebsd.org/changeset/base/292636

Log:
  MFC r271026,r271027,r271028:
  
  r271026 (by pjd):
  
  Fix descriptors leak in case of nvlist_xunpack() failure.
  
  Submitted by:	Mariusz Zaborski <oshogbo at FreeBSD.org>
  
  r271027 (by pjd):
  
  Declare i.
  
  Reported by:	sbruno
  
  r271028 (by pjd):
  
  Use better type for i.

Modified:
  user/ngie/stable-10-libnv/lib/libnv/nvlist.c
Directory Properties:
  user/ngie/stable-10-libnv/   (props changed)

Modified: user/ngie/stable-10-libnv/lib/libnv/nvlist.c
==============================================================================
--- user/ngie/stable-10-libnv/lib/libnv/nvlist.c	Tue Dec 22 23:10:18 2015	(r292635)
+++ user/ngie/stable-10-libnv/lib/libnv/nvlist.c	Tue Dec 22 23:11:49 2015	(r292636)
@@ -892,7 +892,7 @@ nvlist_recv(int sock)
 	struct nvlist_header nvlhdr;
 	nvlist_t *nvl, *ret;
 	unsigned char *buf;
-	size_t nfds, size;
+	size_t nfds, size, i;
 	int serrno, *fds;
 
 	if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr)) == -1)
@@ -925,8 +925,11 @@ nvlist_recv(int sock)
 	}
 
 	nvl = nvlist_xunpack(buf, size, fds, nfds);
-	if (nvl == NULL)
+	if (nvl == NULL) {
+		for (i = 0; i < nfds; i++)
+			close(fds[i]);
 		goto out;
+	}
 
 	ret = nvl;
 out:


More information about the svn-src-user mailing list