Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/usr.sbin/greconfig Pull up revision 1.7 (requested by m...
details: https://anonhg.NetBSD.org/src/rev/a34a72be4050
branches: netbsd-1-6
changeset: 529209:a34a72be4050
user: tron <tron%NetBSD.org@localhost>
date: Fri Nov 01 11:21:57 2002 +0000
description:
Pull up revision 1.7 (requested by martin in ticket #225):
Avoid a NULL pointer access if passed bogus parameters.
Unify exit codes to EXIST_SUCCESS/EXIT_FAILURE.
diffstat:
usr.sbin/greconfig/greconfig.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diffs (70 lines):
diff -r 596adce95f79 -r a34a72be4050 usr.sbin/greconfig/greconfig.c
--- a/usr.sbin/greconfig/greconfig.c Fri Nov 01 11:14:06 2002 +0000
+++ b/usr.sbin/greconfig/greconfig.c Fri Nov 01 11:21:57 2002 +0000
@@ -37,7 +37,7 @@
/*
* greconfig - frontend to set/query tunnel endpoints
*
- * $NetBSD: greconfig.c,v 1.6 1999/09/30 12:35:54 soren Exp $
+ * $NetBSD: greconfig.c,v 1.6.8.1 2002/11/01 11:21:57 tron Exp $
*/
#include <stdio.h>
@@ -106,28 +106,28 @@
break;
default:
usage();
- exit(1);
+ exit(EXIT_FAILURE);
}
if (inf == NULL) {
usage();
- exit(2);
+ exit(EXIT_FAILURE);
}
if (strncmp("gre", inf, 3) != 0) {
usage();
- exit(3);
+ exit(EXIT_FAILURE);
}
if ((proto != 47) && (proto != 55)) {
usage();
- exit(4);
+ exit(EXIT_FAILURE);
}
s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) {
perror("socket() failed:");
- exit(5);
+ exit(EXIT_FAILURE);
}
if (pflag) { /* IPPROTO_GRE is default in kernel */
strncpy(ifr.ifr_name, inf, sizeof(ifr.ifr_name));
@@ -181,7 +181,7 @@
}
close(s);
- exit(0);
+ exit(EXIT_SUCCESS);
}
void
@@ -200,11 +200,13 @@
static struct sockaddr_in s;
hp = gethostbyname(name);
+ if (hp == NULL)
+ errx(EXIT_FAILURE, "Host \"%s\" not found\n", name);
bzero(&s, sizeof(struct sockaddr_in));
s.sin_family = hp->h_addrtype;
if (hp->h_addrtype != AF_INET)
- errx(5, "Only internet addresses allowed, not %s\n", name);
+ errx(EXIT_FAILURE, "Only internet addresses allowed, not %s\n", name);
bcopy(hp->h_addr, &s.sin_addr, hp->h_length);
si = &s;
Home |
Main Index |
Thread Index |
Old Index