Hi,

sorry for letting this slip through the cracks.

I believe that the attached patch resolves the problem
that you have reported by only checking the value a pointer
if it is non-NULL.



# HG changeset patch
# User Simon Horman <ho...@verge.net.au>
# Date 1410401069 -32400
#      Thu Sep 11 11:04:29 2014 +0900
# Node ID 72a72638d1771fb2066f3ff9036fc9957afc666d
# Parent  bc7779a3aa2c146d904d06a40851fba8049c1904
Check pointers are non-NULL before checking their values

When a pointer is returned by a function check that it is
non-NULL before checking its value.

This is a resolution to the problem reported in Debian Bug #716429
See: https://bugs.debian.org/716429

That bug report exercises the problem of the return value
of the call to vanessa_socket_server_bindv() in
vanessa_socket_server_connectv().

Signed-off-by: Simon Horman <ho...@verge.net.au>

diff -r bc7779a3aa2c -r 72a72638d177 libvanessa_socket/vanessa_socket_server.c
--- a/libvanessa_socket/vanessa_socket_server.c	Thu Sep 11 10:41:40 2014 +0900
+++ b/libvanessa_socket/vanessa_socket_server.c	Thu Sep 11 11:04:29 2014 +0900
@@ -388,7 +388,7 @@
 	for(;;) {
 		addrlen = sizeof(from);
 		*g = accept(listen_socket, (struct sockaddr *) &from, &addrlen);
-		if (*g  < 0) {
+		if (!g || *g  < 0) {
 			if (opt & O_NONBLOCK &&
 			    (errno == EAGAIN || errno == EWOULDBLOCK))
 				return -1; /* Don't log EAGAIN or EWOULDBLOCK */
@@ -755,7 +755,7 @@
 	int g;
 
 	s = vanessa_socket_server_bindv(fromv, flag);
-	if(*s < 0) {
+	if(!s || *s < 0) {
 		VANESSA_LOGGER_DEBUG("vanessa_socket_server_bind_sockaddr_in");
 		return (-1);
 	}

Reply via email to