aboutsummaryrefslogtreecommitdiff
path: root/contrib/bind9/bin/nsupdate/nsupdate.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/bin/nsupdate/nsupdate.c')
-rw-r--r--contrib/bind9/bin/nsupdate/nsupdate.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/contrib/bind9/bin/nsupdate/nsupdate.c b/contrib/bind9/bin/nsupdate/nsupdate.c
index 743f32134687..1f5e3e96c9ef 100644
--- a/contrib/bind9/bin/nsupdate/nsupdate.c
+++ b/contrib/bind9/bin/nsupdate/nsupdate.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -1122,7 +1122,7 @@ parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
isc_buffer_t source;
word = nsu_strsep(cmdlinep, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read owner name\n");
return (STATUS_SYNTAX);
}
@@ -1154,6 +1154,11 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
dns_rdatacallbacks_t callbacks;
isc_result_t result;
+ if (cmdline == NULL) {
+ rdata->flags = DNS_RDATA_UPDATE;
+ return (STATUS_MORE);
+ }
+
while (*cmdline != 0 && isspace((unsigned char)*cmdline))
cmdline++;
@@ -1220,7 +1225,7 @@ make_prereq(char *cmdline, isc_boolean_t ispositive, isc_boolean_t isrrset) {
*/
if (isrrset) {
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read class or type\n");
goto failure;
}
@@ -1236,7 +1241,7 @@ make_prereq(char *cmdline, isc_boolean_t ispositive, isc_boolean_t isrrset) {
* Now read the type.
*/
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read type\n");
goto failure;
}
@@ -1310,7 +1315,7 @@ evaluate_prereq(char *cmdline) {
ddebug("evaluate_prereq()");
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read operation code\n");
return (STATUS_SYNTAX);
}
@@ -1344,14 +1349,14 @@ evaluate_server(char *cmdline) {
}
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read server name\n");
return (STATUS_SYNTAX);
}
server = word;
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0)
+ if (word == NULL || *word == 0)
port = dnsport;
else {
char *endp;
@@ -1385,14 +1390,14 @@ evaluate_local(char *cmdline) {
struct in6_addr in6;
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read server name\n");
return (STATUS_SYNTAX);
}
local = word;
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0)
+ if (word == NULL || *word == 0)
port = 0;
else {
char *endp;
@@ -1441,7 +1446,7 @@ evaluate_key(char *cmdline) {
char *n;
namestr = nsu_strsep(&cmdline, " \t\r\n");
- if (*namestr == 0) {
+ if (namestr == NULL || *namestr == 0) {
fprintf(stderr, "could not read key name\n");
return (STATUS_SYNTAX);
}
@@ -1465,7 +1470,7 @@ evaluate_key(char *cmdline) {
}
secretstr = nsu_strsep(&cmdline, "\r\n");
- if (*secretstr == 0) {
+ if (secretstr == NULL || *secretstr == 0) {
fprintf(stderr, "could not read key secret\n");
return (STATUS_SYNTAX);
}
@@ -1506,7 +1511,7 @@ evaluate_zone(char *cmdline) {
isc_result_t result;
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read zone name\n");
return (STATUS_SYNTAX);
}
@@ -1532,7 +1537,7 @@ evaluate_realm(char *cmdline) {
char buf[1024];
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
if (realm != NULL)
isc_mem_free(mctx, realm);
realm = NULL;
@@ -1557,7 +1562,7 @@ evaluate_ttl(char *cmdline) {
isc_uint32_t ttl;
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not ttl\n");
return (STATUS_SYNTAX);
}
@@ -1591,7 +1596,7 @@ evaluate_class(char *cmdline) {
dns_rdataclass_t rdclass;
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read class name\n");
return (STATUS_SYNTAX);
}
@@ -1649,7 +1654,7 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) {
* If it's a delete, ignore a TTL if present (for compatibility).
*/
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
if (!isdelete) {
fprintf(stderr, "could not read owner ttl\n");
goto failure;
@@ -1690,7 +1695,7 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) {
*/
word = nsu_strsep(&cmdline, " \t\r\n");
parseclass:
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
if (isdelete) {
rdataclass = dns_rdataclass_any;
rdatatype = dns_rdatatype_any;
@@ -1714,7 +1719,7 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) {
* Now read the type.
*/
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
if (isdelete) {
rdataclass = dns_rdataclass_any;
rdatatype = dns_rdatatype_any;
@@ -1794,7 +1799,7 @@ evaluate_update(char *cmdline) {
ddebug("evaluate_update()");
word = nsu_strsep(&cmdline, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read operation code\n");
return (STATUS_SYNTAX);
}
@@ -1884,6 +1889,7 @@ get_next_command(void) {
char cmdlinebuf[MAXCMD];
char *cmdline;
char *word;
+ char *tmp;
ddebug("get_next_command()");
if (interactive) {
@@ -1895,11 +1901,18 @@ get_next_command(void) {
isc_app_unblock();
if (cmdline == NULL)
return (STATUS_QUIT);
+
+ /*
+ * Normalize input by removing any eol.
+ */
+ tmp = cmdline;
+ (void)nsu_strsep(&tmp, "\r\n");
+
word = nsu_strsep(&cmdline, " \t\r\n");
if (feof(input))
return (STATUS_QUIT);
- if (*word == 0)
+ if (word == NULL || *word == 0)
return (STATUS_SEND);
if (word[0] == ';')
return (STATUS_MORE);