aboutsummaryrefslogtreecommitdiff
path: root/src/dns
diff options
context:
space:
mode:
authorgrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2012-01-25 10:22:42 +0000
committergrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2012-01-25 10:22:42 +0000
commit8088f4d24300731c7d4d8861cfedb0c4c88e9ed2 (patch)
treec1cd7d45f5518ec434ea7c383cba00e82011082d /src/dns
parentea3e88b3765aaa60159aedebd724ba37f8778f32 (diff)
-check cmd line argument
git-svn-id: https://gnunet.org/svn/gnunet@19376 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/dns')
-rw-r--r--src/dns/gnunet-dns-redirector.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c
index 41667ee9f5..cea8f5be94 100644
--- a/src/dns/gnunet-dns-redirector.c
+++ b/src/dns/gnunet-dns-redirector.c
@@ -77,7 +77,7 @@ modify_record (const struct GNUNET_DNSPARSER_Record *record)
"Changing A record from `%s' to `%s'\n",
inet_ntop (AF_INET, record->data.raw.data, buf, sizeof (buf)),
n4);
- inet_pton (AF_INET, n4, record->data.raw.data);
+ GNUNET_assert (1 == inet_pton (AF_INET, n4, record->data.raw.data));
}
break;
case GNUNET_DNSPARSER_TYPE_AAAA:
@@ -90,7 +90,7 @@ modify_record (const struct GNUNET_DNSPARSER_Record *record)
"Changing AAAA record from `%s' to `%s'\n",
inet_ntop (AF_INET6, record->data.raw.data, buf, sizeof (buf)),
n6);
- inet_pton (AF_INET6, n6, record->data.raw.data);
+ GNUNET_assert (1 == inet_pton (AF_INET6, n6, record->data.raw.data));
}
break;
case GNUNET_DNSPARSER_TYPE_NS:
@@ -199,6 +199,25 @@ static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ struct in_addr i4;
+ struct in6_addr i6;
+ if ( (n4 != NULL) &&
+ (1 != inet_pton (AF_INET, n4, &i4)) )
+ {
+ fprintf (stderr,
+ "`%s' is nto a valid IPv4 address!\n",
+ n4);
+ return;
+ }
+ if ( (n6 != NULL) &&
+ (1 != inet_pton (AF_INET6, n6, &i6)) )
+ {
+ fprintf (stderr,
+ "`%s' is nto a valid IPv6 address!\n",
+ n6);
+ return;
+ }
+
handle =
GNUNET_DNS_connect (cfg,
GNUNET_DNS_FLAG_POST_RESOLUTION,