From 13762fce1926efb6b553bf20df256ccf6586f518 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Fri, 15 May 2015 10:25:29 +0200 Subject: ripe-atlas-fw: imported version 4670 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- eperd/httpget.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'eperd/httpget.c') diff --git a/eperd/httpget.c b/eperd/httpget.c index 4b22bca..1a8fe09 100644 --- a/eperd/httpget.c +++ b/eperd/httpget.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 RIPE NCC + * Copyright (c) 2013-2014 RIPE NCC * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. * httpget.c -- libevent-based version of httpget */ @@ -627,7 +627,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[], state->max_body= max_body; state->read_limit= read_limit; state->timeout= timeout; - state->infname= infname; + state->infname= infname ? strdup(infname) : NULL; state->only_v4= 2; @@ -744,12 +744,16 @@ static void report(struct hgstate *state) if (state->read_truncated) add_str(state, ", " DBQ(read-truncated) ": True"); - getnameinfo((struct sockaddr *)&state->sin6, state->socklen, - namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST); + if (state->socklen != 0) + { + getnameinfo((struct sockaddr *)&state->sin6, + state->socklen, namebuf, sizeof(namebuf), + NULL, 0, NI_NUMERICHOST); - snprintf(line, sizeof(line), ", " DBQ(dst_addr) ":" DBQ(%s), - namebuf); - add_str(state, line); + snprintf(line, sizeof(line), + ", " DBQ(dst_addr) ":" DBQ(%s), namebuf); + add_str(state, line); + } /* End of readtiming */ if (state->etim >= 2) @@ -1627,7 +1631,7 @@ static void writecb(struct bufferevent *bev, void *ptr) state->do_head ? "HEAD" : "POST", state->path, state->do_http10 ? '0' : '1'); evbuffer_add_printf(output, "Host: %s\r\n", - state->host); + state->hostport); evbuffer_add_printf(output, "Connection: close\r\n"); evbuffer_add_printf(output, "User-Agent: %s\r\n", state->user_agent); @@ -1940,6 +1944,8 @@ static int httpget_delete(void *state) hgstate->atlas= NULL; free(hgstate->output_file); hgstate->output_file= NULL; + free(hgstate->infname); + hgstate->infname= NULL; free(hgstate->host); hgstate->host= NULL; free(hgstate->hostport); -- cgit v1.2.3