]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check returns from putstr and putnull
authorMark Andrews <marka@isc.org>
Tue, 18 Nov 2014 01:21:20 +0000 (12:21 +1100)
committerMark Andrews <marka@isc.org>
Tue, 18 Nov 2014 02:03:20 +0000 (13:03 +1100)
(cherry picked from commit 18fa89b01e2d70d9842e3f504260ea2e8754c15e)

bin/named/server.c

index bb3e72bcf6f1199c56c2578ea21d3cd48f824e11..ac015a42b970e92acfb6a72eeb7d30ac4e801ae0 100644 (file)
@@ -7392,7 +7392,7 @@ ns_server_validation(ns_server_t *server, char *args) {
                        continue;
                result = dns_view_flushcache(view);
                if (result != ISC_R_SUCCESS)
-                       goto out;
+                       goto cleanup;
                view->enablevalidation = enable;
                changed = ISC_TRUE;
        }
@@ -7400,7 +7400,7 @@ ns_server_validation(ns_server_t *server, char *args) {
                result = ISC_R_SUCCESS;
        else
                result = ISC_R_FAILURE;
out:
cleanup:
        isc_task_endexclusive(server->task);
        return (result);
 }
@@ -7805,7 +7805,6 @@ list_keynames(dns_view_t *view, dns_tsig_keyring_t *ring, isc_buffer_t *text,
        dns_name_t *origin;
        dns_rbtnode_t *node;
        dns_tsigkey_t *tkey;
-       unsigned int n;
        const char *viewname;
 
        if (view != NULL)
@@ -7839,21 +7838,26 @@ list_keynames(dns_view_t *view, dns_tsig_keyring_t *ring, isc_buffer_t *text,
                        if (tkey->generated) {
                                dns_name_format(tkey->creator, creatorstr,
                                                sizeof(creatorstr));
-                               n = snprintf((char *)isc_buffer_used(text),
-                                            isc_buffer_availablelength(text),
-                                            "view \"%s\"; type \"dynamic\"; key \"%s\"; creator \"%s\";\n",
-                                            viewname, namestr, creatorstr);
+                               if (*foundkeys != 0)
+                                       CHECK(putstr(text, "\n"));
+                               CHECK(putstr(text, "view \""));
+                               CHECK(putstr(text, viewname));
+                               CHECK(putstr(text,
+                                            "\"; type \"dynamic\"; key \""));
+                               CHECK(putstr(text, namestr));
+                               CHECK(putstr(text, "\"; creator \""));
+                               CHECK(putstr(text, creatorstr));
+                               CHECK(putstr(text, "\";"));
                        } else {
-                               n = snprintf((char *)isc_buffer_used(text),
-                                            isc_buffer_availablelength(text),
-                                            "view \"%s\"; type \"static\"; key \"%s\";\n",
-                                            viewname, namestr);
-                       }
-                       if (n >= isc_buffer_availablelength(text)) {
-                               dns_rbtnodechain_invalidate(&chain);
-                               return (ISC_R_NOSPACE);
+                               if (*foundkeys != 0)
+                                       CHECK(putstr(text, "\n"));
+                               CHECK(putstr(text, "view \""));
+                               CHECK(putstr(text, viewname));
+                               CHECK(putstr(text,
+                                            "\"; type \"static\"; key \""));
+                               CHECK(putstr(text, namestr));
+                               CHECK(putstr(text, "\";"));
                        }
-                       isc_buffer_add(text, n);
                }
                result = dns_rbtnodechain_next(&chain, &foundname, origin);
                if (result == ISC_R_NOMORE)
@@ -7865,12 +7869,14 @@ list_keynames(dns_view_t *view, dns_tsig_keyring_t *ring, isc_buffer_t *text,
        }
 
        return (ISC_R_SUCCESS);
+
+cleanup:
+       return (result);
 }
 
 isc_result_t
 ns_server_tsiglist(ns_server_t *server, isc_buffer_t *text) {
        isc_result_t result;
-       unsigned int n;
        dns_view_t *view;
        unsigned int foundkeys = 0;
 
@@ -7898,16 +7904,16 @@ ns_server_tsiglist(ns_server_t *server, isc_buffer_t *text) {
        }
        isc_task_endexclusive(server->task);
 
-       if (foundkeys == 0) {
-               n = snprintf((char *)isc_buffer_used(text),
-                            isc_buffer_availablelength(text),
-                            "no tsig keys found.\n");
-               if (n >= isc_buffer_availablelength(text))
-                       return (ISC_R_NOSPACE);
-               isc_buffer_add(text, n);
-       }
+       if (foundkeys == 0)
+               CHECK(putstr(text, "no tsig keys found."));
+
+       if (isc_buffer_usedlength(text) > 0)
+               CHECK(putnull(text));
 
        return (ISC_R_SUCCESS);
+
+ cleanup:
+       return (result);
 }
 
 /*