summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-06-18 17:02:42 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-06-18 17:02:42 +0000
commita4662254135ddf6ad3fb84701a6ac6196cec35c9 (patch)
tree822c47b0926cf6f45052d4456b42de473852c124 /sbin/dhclient
parent2a1a5417f46cb68e1300f5e4f0c9b836b9587a7b (diff)
Don't use inet_ntoa() twice in one parameter list. You'll just print
one of the strings twice. Spotted by mpi@, who also tweaked the diff by pointing out INET_ADDRSTRLEN. Should fix mysterious messages like "1.2.3.4, not 1.2.3.4, deleted from ...".
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 38e5c3e328a..773c7668c67 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.256 2013/06/18 00:30:39 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.257 2013/06/18 17:02:41 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -176,6 +176,7 @@ get_ifa(char *cp, int n)
void
routehandler(void)
{
+ char ntoabuf[INET_ADDRSTRLEN];
struct in_addr a, b;
ssize_t n;
int linkstat, rslt;
@@ -236,11 +237,11 @@ routehandler(void)
if ((client->flags & IS_RESPONSIBLE) == 0)
/* We're not responsible yet! */
break;
- if (adding.s_addr != INADDR_ANY)
- rslt = asprintf(&errmsg, "%s, not %s, added "
- "to %s", inet_ntoa(a), inet_ntoa(adding),
- ifi->name);
- else
+ if (adding.s_addr != INADDR_ANY) {
+ strlcpy(ntoabuf, inet_ntoa(a), sizeof(ntoabuf));
+ rslt = asprintf(&errmsg, "%s, not %s, added to %s",
+ ntoabuf, inet_ntoa(adding), ifi->name);
+ } else
rslt = asprintf(&errmsg, "%s added to %s",
inet_ntoa(a), ifi->name);
goto die;
@@ -283,11 +284,11 @@ routehandler(void)
quit = INTERNALSIG;
break;
}
- if (deleting.s_addr != INADDR_ANY)
- rslt = asprintf(&errmsg, "%s, not %s, deleted "
- "from %s", inet_ntoa(a),
- inet_ntoa(deleting), ifi->name);
- else
+ if (deleting.s_addr != INADDR_ANY) {
+ strlcpy(ntoabuf, inet_ntoa(a), sizeof(ntoabuf));
+ rslt = asprintf(&errmsg, "%s, not %s, deleted from %s",
+ ntoabuf, inet_ntoa(deleting), ifi->name);
+ } else
rslt = asprintf(&errmsg, "%s deleted from %s",
inet_ntoa(a), ifi->name);
goto die;