DragonFly BSD
DragonFly bugs List (threaded) for 2013-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

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


From: Jerome Portal via Redmine <bugtracker-admin@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 5 Apr 2013 09:13:45 -0700

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



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]