aboutsummaryrefslogtreecommitdiff
path: root/eperd/ntp.c
diff options
context:
space:
mode:
Diffstat (limited to 'eperd/ntp.c')
-rw-r--r--eperd/ntp.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/eperd/ntp.c b/eperd/ntp.c
index 251510d..457f34a 100644
--- a/eperd/ntp.c
+++ b/eperd/ntp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 RIPE NCC <atlas@ripe.net>
+ * Copyright (c) 2013-2014 RIPE NCC <atlas@ripe.net>
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* traceroute.c
*/
@@ -342,12 +342,16 @@ static void report(struct ntpstate *state)
fprintf(fh, ", " DBQ(dst_addr) ":" DBQ(%s), namebuf);
- namebuf[0]= '\0';
- getnameinfo((struct sockaddr *)&state->loc_sin6,
- state->loc_socklen,
- namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
+ if (state->loc_socklen != 0)
+ {
+ namebuf[0]= '\0';
+ getnameinfo((struct sockaddr *)&state->loc_sin6,
+ state->loc_socklen,
+ namebuf, sizeof(namebuf), NULL, 0,
+ NI_NUMERICHOST);
- fprintf(fh, ", " DBQ(src_addr) ":" DBQ(%s), namebuf);
+ fprintf(fh, ", " DBQ(src_addr) ":" DBQ(%s), namebuf);
+ }
}
proto= "UDP";
@@ -1655,7 +1659,7 @@ static void *ntp_init(int __attribute((unused)) argc, char *argv[],
state= xzalloc(sizeof(*state));
state->count= count;
- state->interface= interface;
+ state->interface= interface ? strdup(interface) : NULL;
state->destportstr= strdup(destportstr);
state->timeout= timeout*1000;
state->atlas= str_Atlas ? strdup(str_Atlas) : NULL;
@@ -1764,7 +1768,7 @@ static int create_socket(struct ntpstate *state)
serrno= errno;
snprintf(line, sizeof(line),
- ", " DBQ(error) ":" DBQ(socket failed: %s) " }",
+ "{ " DBQ(error) ":" DBQ(socket failed: %s) " }",
strerror(serrno));
add_str(state, line);
report(state);
@@ -1777,7 +1781,7 @@ static int create_socket(struct ntpstate *state)
af, state->interface) == -1)
{
snprintf(line, sizeof(line),
- ", " DBQ(error) ":" DBQ(bind_interface failed) " }");
+ "{ " DBQ(error) ":" DBQ(bind_interface failed) " }");
add_str(state, line);
report(state);
return -1;
@@ -1945,6 +1949,8 @@ static int ntp_delete(void *state)
ntpstate->destportstr= NULL;
free(ntpstate->out_filename);
ntpstate->out_filename= NULL;
+ free(ntpstate->interface);
+ ntpstate->interface= NULL;
free(ntpstate);