summaryrefslogtreecommitdiffstats
path: root/contrib/bind/bin/ndc/ndc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind/bin/ndc/ndc.c')
-rw-r--r--contrib/bind/bin/ndc/ndc.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/contrib/bind/bin/ndc/ndc.c b/contrib/bind/bin/ndc/ndc.c
index 764d05b..7235586 100644
--- a/contrib/bind/bin/ndc/ndc.c
+++ b/contrib/bind/bin/ndc/ndc.c
@@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: ndc.c,v 1.13 1999/10/13 16:39:16 vixie Exp $";
+static const char rcsid[] = "$Id: ndc.c,v 1.14 2000/02/04 08:28:32 vixie Exp $";
#endif /* not lint */
/*
@@ -47,7 +47,9 @@ static const char rcsid[] = "$Id: ndc.c,v 1.13 1999/10/13 16:39:16 vixie Exp $";
typedef union {
struct sockaddr_in in;
+#ifndef NO_SOCKADDR_UN
struct sockaddr_un un;
+#endif
} sockaddr_t;
typedef void (*closure)(void *, const char *, int);
@@ -603,22 +605,29 @@ static int
get_sockaddr(char *name, sockaddr_t *addr) {
char *slash;
+#ifndef NO_SOCKADDR_UN
if (name[0] == '/') {
memset(&addr->un, '\0', sizeof addr->un);
addr->un.sun_family = AF_UNIX;
strncpy(addr->un.sun_path, name, sizeof addr->un.sun_path - 1);
addr->un.sun_path[sizeof addr->un.sun_path - 1] = '\0';
- } else if ((slash = strrchr(name, '/')) != NULL) {
- *slash = '\0';
+ } else
+#endif
+ if ((slash = strrchr(name, '/')) != NULL) {
+ char *ibuf = malloc(slash - name + 1);
+ if (!ibuf)
+ usage("no memory for IP address (%s)", name);
+ memcpy(ibuf, name, slash - name);
+ ibuf[slash - name] = '\0';
memset(&addr->in, '\0', sizeof addr->in);
- if (!inet_pton(AF_INET, name, &addr->in.sin_addr))
+ if (!inet_pton(AF_INET, ibuf, &addr->in.sin_addr))
usage("bad ip address (%s)", name);
if ((addr->in.sin_port = htons(atoi(slash+1))) == 0)
usage("bad ip port (%s)", slash+1);
addr->in.sin_family = AF_INET;
- *slash = ':';
- } else {
- return (0);
+ free (ibuf);
+ } else {
+ return (0);
}
return (1);
}
@@ -630,8 +639,10 @@ impute_addrlen(const struct sockaddr *sa) {
switch (sa->sa_family) {
case AF_INET:
return (sizeof(struct sockaddr_in));
+#ifndef NO_SOCKADDR_UN
case AF_UNIX:
return (sizeof(struct sockaddr_un));
+#endif
default:
abort();
}
OpenPOWER on IntegriCloud