]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3379. [bug] nsupdate terminated unexpectedly in interactive mode
authorMark Andrews <marka@isc.org>
Wed, 22 Aug 2012 03:38:51 +0000 (13:38 +1000)
committerMark Andrews <marka@isc.org>
Wed, 22 Aug 2012 03:54:02 +0000 (13:54 +1000)
                        if built with readline support. [RT #29550]

CHANGES
bin/nsupdate/nsupdate.c
bin/tests/system/nsupdate/commandlist [new file with mode: 0644]
bin/tests/system/nsupdate/tests.sh

diff --git a/CHANGES b/CHANGES
index 05d0ddfd72cb5a72398c277f5dfae12e25ac3051..58290f39f87f7579f277ffaf4f73d88a3edd4bbb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3379.  [bug]           nsupdate terminated unexpectedly in interactive mode
+                       if built with readline support. [RT #29550]
+
 3368.  [bug]           <dns/iptable.h> and <dns/zone.h> were not C++ safe.
 
 3367.  [bug]           dns_dnsseckey_create() result was not being checked.
index 3db3e9f73363dad0dcbedcfa11f8995b747d51ab..b0b11774c8116aafbb5d0bea26cf5bfe2080bffe 100644 (file)
@@ -1121,7 +1121,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);
        }
@@ -1219,7 +1219,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;
                }
@@ -1235,7 +1235,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;
                        }
@@ -1309,7 +1309,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);
        }
@@ -1343,14 +1343,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;
@@ -1384,14 +1384,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;
@@ -1440,7 +1440,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);
        }
@@ -1464,7 +1464,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);
        }
@@ -1505,7 +1505,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);
        }
@@ -1531,7 +1531,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;
@@ -1556,7 +1556,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);
        }
@@ -1590,7 +1590,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);
        }
@@ -1648,7 +1648,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;
@@ -1689,7 +1689,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;
@@ -1713,7 +1713,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;
@@ -1793,7 +1793,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);
        }
@@ -1883,6 +1883,7 @@ get_next_command(void) {
        char cmdlinebuf[MAXCMD];
        char *cmdline;
        char *word;
+       char *tmp;
 
        ddebug("get_next_command()");
        if (interactive) {
@@ -1894,11 +1895,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);
diff --git a/bin/tests/system/nsupdate/commandlist b/bin/tests/system/nsupdate/commandlist
new file mode 100644 (file)
index 0000000..41c8049
--- /dev/null
@@ -0,0 +1,15 @@
+server 127.0.0.1
+server 127.0.0.1 port
+update
+update delete
+update delete dummy
+update delete dummy in
+update delete dummy in a
+update delete dummy in a 127.0.0.1
+update add
+update add domain
+update add domain 0
+update add domain 0 in
+update add domain 0 in a
+update add domain 0 a
+update add domain 0 a in
index ea858dcc13bff79ca2b54beec5f879cf5bbf3132..46cc1b3d228d03e2cc0800184be05a0c5b03882f 100644 (file)
@@ -428,5 +428,28 @@ then
 echo "I:failed"; status=1
 fi
 
+n=`expr $n + 1`
+ret=0
+echo "I:check command list ($n)"
+(
+while read cmd 
+do
+    echo "$cmd" | $NSUPDATE  > /dev/null 2>&1
+    if test $? -gt 1 ; then
+       echo "I: failed ($cmd)"
+       ret=1
+    fi
+    echo "$cmd " | $NSUPDATE  > /dev/null 2>&1
+    if test $? -gt 1 ; then
+       echo "I: failed ($cmd)"
+       ret=1
+    fi
+done
+exit $ret
+) < commandlist || ret=1
+if [ $ret -ne 0 ]; then
+    status=1
+fi
+
 echo "I:exit status: $status"
 exit $status