[BusyBox-cvs] busybox/libbb xconnect.c,1.9,1.10
Erik Andersen
andersen at busybox.net
Tue Dec 23 20:37:25 UTC 2003
Update of /var/cvs/busybox/libbb
In directory nail:/tmp/cvs-serv6773/libbb
Modified Files:
xconnect.c
Log Message:
don't mess up errno
Index: xconnect.c
===================================================================
RCS file: /var/cvs/busybox/libbb/xconnect.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- xconnect.c 20 Dec 2003 01:47:17 -0000 1.9
+++ xconnect.c 23 Dec 2003 20:37:23 -0000 1.10
@@ -27,9 +27,15 @@
{
unsigned short port_nr = htons(default_port);
if (port) {
- char *endptr;
- long port_long = strtol(port, &endptr, 10);
+ char *endptr;
+ int old_errno;
+ long port_long;
+ /* Since this is a lib function, we're not allowed to reset errno to 0.
+ * Doing so could break an app that is deferring checking of errno. */
+ old_errno = errno;
+ errno = 0;
+ port_long = strtol(port, &endptr, 10);
if (errno != 0 || *endptr!='\0' || endptr==port || port_long < 0 || port_long > 65535) {
struct servent *tserv = getservbyname(port, "tcp");
if (tserv) {
@@ -38,6 +44,7 @@
} else {
port_nr = htons(port_long);
}
+ errno = old_errno;
}
return port_nr;
}
More information about the busybox-cvs
mailing list