From eb612bfdfc2801ddb44c5db3352beb867b5c4868 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 17 Oct 2008 11:26:36 +0000 Subject: Charles Hardin made adig support a regular numerical dotted IP address for the -s option as well. --- ares/CHANGES | 4 ++++ ares/adig.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'ares') diff --git a/ares/CHANGES b/ares/CHANGES index 68ec05d5a..c64ad799e 100644 --- a/ares/CHANGES +++ b/ares/CHANGES @@ -1,5 +1,9 @@ Changelog for the c-ares project +* Oct 18 2008 (Daniel Stenberg) + Charles Hardin made adig support a regular numerical dotted IP address for the + -s option as well. + * Oct 7 2008 (Yang Tse) - Added --enable-optimize configure option to enable and disable compiler optimizations to allow decoupled setting from --enable-debug. diff --git a/ares/adig.c b/ares/adig.c index 0dfc8bd26..cc0d42d56 100644 --- a/ares/adig.c +++ b/ares/adig.c @@ -151,6 +151,7 @@ static const char *opcodes[] = { "UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA", "ZONEINIT", "ZONEREF" }; + struct in_addr inaddr; static const char *rcodes[] = { "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED", @@ -212,11 +213,15 @@ int main(int argc, char **argv) case 's': /* Add a server, and specify servers in the option mask. */ - hostent = gethostbyname(optarg); - if (!hostent || hostent->h_addrtype != AF_INET) + if (inet_pton(AF_INET, optarg, &inaddr) <= 0) { - fprintf(stderr, "adig: server %s not found.\n", optarg); - return 1; + hostent = gethostbyname(optarg); + if (!hostent || hostent->h_addrtype != AF_INET) + { + fprintf(stderr, "adig: server %s not found.\n", optarg); + return 1; + } + memcpy(&inaddr, hostent->h_addr, sizeof(struct in_addr)); } options.servers = realloc(options.servers, (options.nservers + 1) * sizeof(struct in_addr)); @@ -225,7 +230,7 @@ int main(int argc, char **argv) fprintf(stderr, "Out of memory!\n"); return 1; } - memcpy(&options.servers[options.nservers], hostent->h_addr, + memcpy(&options.servers[options.nservers], &inaddr, sizeof(struct in_addr)); options.nservers++; optmask |= ARES_OPT_SERVERS; -- cgit v1.2.3