[DragonFlyBSD - Bug #2136] socketpair() doesn't free file descriptors on copyout failure

Jerome Portal via Redmine bugtracker-admin at leaf.dragonflybsd.org
Fri Apr 5 09:13:45 PDT 2013


Issue #2136 has been updated by jerome.

File 0001-linux_socketpair-Free-socketpair-file-descriptors-if.patch added

Here is a patch that, I think, fix linux_socketpair(), in the same way sys_socketpair() was fixed.

---
 sys/emulation/linux/linux_socket.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/emulation/linux/linux_socket.c b/sys/emulation/linux/linux_socket.c
index b60870a..55644aa 100644
--- a/sys/emulation/linux/linux_socket.c
+++ b/sys/emulation/linux/linux_socket.c
@@ -556,8 +556,15 @@ linux_socketpair(struct linux_socketpair_args *args, int *res)
 	error = kern_socketpair(domain, linux_args.type, linux_args.protocol,
 	    sockv);
 
-	if (error == 0)
+	if (error == 0) {
 		error = copyout(sockv, linux_args.rsv, sizeof(sockv));
+		
+		if (error != 0) {
+			kern_close(sockv[0]);
+			kern_close(sockv[1]);
+		}
+	}
+
 	return(error);
 }
 
-- 
----------------------------------------
Bug #2136: socketpair() doesn't free file descriptors on copyout failure
http://bugs.dragonflybsd.org/issues/2136

Author: vsrinivas
Status: New
Priority: Normal
Assignee: 
Category: 
Target version: 


Hi,

sys_socketpair() has a copyout() to copy two file descriptors back to userspace;
if this copyout fails, the socketpair file descriptors are not freed.

-- vs


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Bugs mailing list