From 4dde583bc91985c3ff19ac1d1f1bc791b50658ff Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 6 Sep 2000 11:49:05 +0000 Subject: [PATCH] - Use strerror() instead of sys_errlist[] for increased portability (Needed for SunOS) --- src/conf.c | 4 ++-- src/net.c | 20 ++++++++++---------- src/netutl.c | 5 +++-- src/tincd.c | 9 +++++---- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/conf.c b/src/conf.c index bfa0fee1..deb2e4a9 100644 --- a/src/conf.c +++ b/src/conf.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.c,v 1.9.4.8 2000/08/09 14:02:15 guus Exp $ + $Id: conf.c,v 1.9.4.9 2000/09/06 11:49:03 guus Exp $ */ @@ -214,7 +214,7 @@ read_config_file(const char *fname) cp if((fp = fopen (fname, "r")) == NULL) { - fprintf(stderr, _("Could not open %s: %s\n"), fname, sys_errlist[errno]); + fprintf(stderr, _("Could not open %s: %s\n"), fname, strerror(errno)); return 1; } diff --git a/src/net.c b/src/net.c index 7d780608..72c1b5e1 100644 --- a/src/net.c +++ b/src/net.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.26 2000/08/09 14:02:16 guus Exp $ + $Id: net.c,v 1.35.4.27 2000/09/06 11:49:03 guus Exp $ */ #include "config.h" @@ -934,7 +934,7 @@ cp if(x) { syslog(LOG_ERR, _("Incoming data socket error for %s (%s): %s"), - cl->vpn_hostname, cl->real_hostname, sys_errlist[x]); + cl->vpn_hostname, cl->real_hostname, strerror(x)); return -1; } @@ -1132,13 +1132,7 @@ cp if(x) { syslog(LOG_ERR, _("Metadata socket error for %s (%s): %s"), - cl->vpn_hostname, cl->real_hostname, sys_errlist[x]); - return -1; - } - - if(cl->buflen >= MAXBUFSIZE) - { - syslog(LOG_ERR, _("Metadata read buffer overflow!")); + cl->vpn_hostname, cl->real_hostname, strerror(x)); return -1; } @@ -1233,6 +1227,12 @@ cp } } + if(cl->buflen >= MAXBUFSIZE) + { + syslog(LOG_ERR, _("Metadata read buffer overflow!")); + return -1; + } + cl->last_ping_time = time(NULL); cl->want_ping = 0; cp @@ -1264,7 +1264,7 @@ cp */ getsockopt(p->socket, SOL_SOCKET, SO_ERROR, &x, &l); syslog(LOG_ERR, _("Outgoing data socket error for %s (%s): %s"), - p->vpn_hostname, p->real_hostname, sys_errlist[x]); + p->vpn_hostname, p->real_hostname, strerror(x)); terminate_connection(p); return; } diff --git a/src/netutl.c b/src/netutl.c index f3ef1341..d0ac628a 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: netutl.c,v 1.12.4.7 2000/08/17 16:51:07 guus Exp $ + $Id: netutl.c,v 1.12.4.8 2000/09/06 11:49:05 guus Exp $ */ #include "config.h" @@ -33,6 +33,7 @@ #include #include +#include "errno.h" #include "conf.h" #include "encr.h" #include "net.h" @@ -217,7 +218,7 @@ cp if(!(h = gethostbyname(p))) { - fprintf(stderr, _("Error looking up `%s': %s\n"), p, sys_errlist[h_errno]); + fprintf(stderr, _("Error looking up `%s': %s\n"), p, strerror(errno)); return NULL; } diff --git a/src/tincd.c b/src/tincd.c index 0e0bc158..fcd70522 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: tincd.c,v 1.10.4.8 2000/08/17 16:51:08 guus Exp $ + $Id: tincd.c,v 1.10.4.9 2000/09/06 11:49:05 guus Exp $ */ #include "config.h" @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef HAVE_SYS_IOCTL_H # include @@ -454,10 +455,10 @@ RETSIGTYPE sighuh(int a) { if(cp_file) - syslog(LOG_NOTICE, _("Got unexpected signal %d after %s line %d"), - a, cp_file, cp_line); + syslog(LOG_NOTICE, _("Got unexpected %s after %s line %d"), + strsignal(a), cp_file, cp_line); else - syslog(LOG_NOTICE, _("Got unexpected signal %d"), a); + syslog(LOG_NOTICE, _("Got unexpected %s"), strsignal(a)); } void -- 2.20.1