ctdb: strip trailing spaces from nodes file.
authorMichael Adam <obnox at samba.org>
Fri, 26 Jun 2015 14:24:55 +0000 (16:24 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 27 Jun 2015 11:20:18 +0000 (13:20 +0200)
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Jun 27 13:20:18 CEST 2015 on sn-devel-104

ctdb/common/ctdb_util.c

index 5d63c2729261a574417fb7a3993df3edbfd775f4..709c7a15b6b246a66c642e72dd57dedf53c810ef 100644 (file)
@@ -548,15 +548,26 @@ struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
        }
 
        for (i=0; i < nlines; i++) {
-               const char *node;
+               char *node;
                uint32_t flags;
+               size_t len;
 
                node = lines[i];
                /* strip leading spaces */
                while((*node == ' ') || (*node == '\t')) {
                        node++;
                }
-               if (strcmp(node, "") == 0) {
+
+               len = strlen(node);
+
+               while ((len > 1) &&
+                      ((node[len-1] == ' ') || (node[len-1] == '\t')))
+               {
+                       node[len-1] = '\0';
+                       len--;
+               }
+
+               if (len == 0) {
                        continue;
                }
                if (*node == '#') {
@@ -566,7 +577,7 @@ struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
                           would cause subsequent nodes to change
                           their PNN. */
                        flags = NODE_FLAGS_DELETED;
-                       node = "0.0.0.0";
+                       node = discard_const("0.0.0.0");
                } else {
                        flags = 0;
                }