user/4999: close(2) clobbers errno in ftp(1)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

user/4999: close(2) clobbers errno in ftp(1)

Ray Lai-2
>Number:         4999
>Category:       user
>Synopsis:       close(2) clobbers errno in ftp(1)
>Confidential:   yes
>Severity:       non-critical
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:      
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 01 07:20:02 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Ray Lai
>Release:        3.9-beta
>Organization:
net
>Environment:
       
        System      : OpenBSD 3.9
        Architecture: OpenBSD.i386
        Machine     : i386
>Description:
close(2) can clobber errno.

>How-To-Repeat:

>Fix:
Index: fetch.c
===================================================================
RCS file: /home/ray/openbsd/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.56
diff -u -r1.56 fetch.c
--- fetch.c 5 Aug 2005 21:01:53 -0000 1.56
+++ fetch.c 31 Jan 2006 07:44:43 -0000
@@ -309,9 +309,13 @@
 
 again:
  if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+ int save_errno;
+
  if (errno == EINTR)
  goto again;
+ save_errno = errno;
  close(s);
+ errno = save_errno;
  s = -1;
  cause = "connect";
  continue;


>Release-Note:
>Audit-Trail:
>Unformatted: