close() clobbers errno in ftp(1)

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

close() clobbers errno in ftp(1)

Ray Lai
Hi,

This diff prevents close() from clobbering errno in ftp/ftp.c.

-Ray-

Index: ftp.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/ftp.c,v
retrieving revision 1.59
diff -u -r1.59 ftp.c
--- ftp.c 13 Nov 2005 20:26:09 -0000 1.59
+++ ftp.c 7 Jan 2006 23:48:06 -0000
@@ -200,7 +200,10 @@
  warn("connect to address %s", hbuf);
  }
  cause = "connect";
+ /* Prevent close() from clobbering errno. */
+ error = errno;
  close(s);
+ errno = error;
  s = -1;
  continue;
  }