From ee0722e2b9c46dd1a66b70f88408559c7b7b1262 Mon Sep 17 00:00:00 2001 From: kardel Date: Sat, 18 Mar 2006 13:13:25 +0000 Subject: [PATCH] avoid close(-1): don't attempt to cleanup INVALID_SOCKET ( ==-1 ) fd's - would lead to close(-1) and FD_CLR((u_int)-1(!), ...) (Coverity CID 1281 NetBSD Scan 5) --- dist/ntp/ntpd/ntp_io.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dist/ntp/ntpd/ntp_io.c b/dist/ntp/ntpd/ntp_io.c index 2cc1a7c77ef4..92cccc5b3c51 100644 --- a/dist/ntp/ntpd/ntp_io.c +++ b/dist/ntp/ntpd/ntp_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: ntp_io.c,v 1.12 2005/06/03 16:13:33 lukem Exp $ */ +/* $NetBSD: ntp_io.c,v 1.13 2006/03/18 13:13:25 kardel Exp $ */ /* * ntp_io.c - input/output routines for ntpd. The socket-opening code @@ -1273,6 +1273,9 @@ close_socket( { SOCKET i, newmax; + if (fd == INVALID_SOCKET) + return; + (void) closesocket(fd); /* @@ -1306,6 +1309,9 @@ close_file( { int i, newmax; + if (fd == INVALID_SOCKET) + return; + (void) close(fd); /* * I/O Completion Ports don't care about select and fd_set