summaryrefslogtreecommitdiff
path: root/bin/nsupdate/nsupdate.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/nsupdate/nsupdate.c')
-rw-r--r--bin/nsupdate/nsupdate.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c
index 3c10b5fd369f..5f25d3c68848 100644
--- a/bin/nsupdate/nsupdate.c
+++ b/bin/nsupdate/nsupdate.c
@@ -1011,7 +1011,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);
}
@@ -1044,6 +1044,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++;
@@ -1110,7 +1115,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;
}
@@ -1126,7 +1131,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;
}
@@ -1200,7 +1205,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);
}
@@ -1229,14 +1234,14 @@ evaluate_server(char *cmdline) {
long port;
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 = DNSDEFAULTPORT;
else {
char *endp;
@@ -1270,14 +1275,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;
@@ -1326,7 +1331,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);
}
@@ -1350,7 +1355,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);
}
@@ -1391,7 +1396,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);
}
@@ -1418,7 +1423,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;
@@ -1443,7 +1448,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);
}
@@ -1477,7 +1482,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);
}
@@ -1535,7 +1540,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;
@@ -1576,7 +1581,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;
@@ -1600,7 +1605,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;
@@ -1680,7 +1685,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);
}
@@ -1770,6 +1775,7 @@ get_next_command(void) {
char cmdlinebuf[MAXCMD];
char *cmdline;
char *word;
+ char *tmp;
ddebug("get_next_command()");
if (interactive) {
@@ -1781,11 +1787,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);