Skip to content
Browse files

Refactor: fencing: Some additional debugging for parse_host_line()

  • Loading branch information...
1 parent 7a0d70f commit 3b39c527683c4e90dfdafbb94dc2c586f20b1126 @beekhof committed Mar 21, 2013
Showing with 10 additions and 6 deletions.
  1. +10 −6 fencing/commands.c
View
16 fencing/commands.c
@@ -425,7 +425,7 @@ parse_host_line(const char *line, GListPtr * output)
return;
}
- crm_trace("Processing: %s", line);
+ crm_trace("Processing: [%s]", line);
/* Skip initial whitespace */
for (lpc = 0; lpc <= max && isspace(line[lpc]); lpc++) {
last = lpc + 1;
@@ -479,11 +479,15 @@ parse_host_list(const char *hosts)
for (lpc = 0; lpc <= max; lpc++) {
if (hosts[lpc] == '\n' || hosts[lpc] == 0) {
char *line = NULL;
-
- line = calloc(1, 2 + lpc - last);
- snprintf(line, 1 + lpc - last, "%s", hosts + last);
- parse_host_line(line, &output);
- free(line);
+ int len = lpc - last;
+
+ if(len > 1) {
+ line = calloc(1, 2 + len);
+ snprintf(line, 1 + len, "%s", hosts + last);
+ line[len] = 0;
+ parse_host_line(line, &output);
+ free(line);
+ }
last = lpc + 1;
}

0 comments on commit 3b39c52

Please sign in to comment.
Something went wrong with that request. Please try again.