X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Fconffile.c;h=3990578084f9c6e36e4d0a9eadbb6da73cdde13c;hb=refs%2Ftags%2Fnfs-utils-1-2-6-rc3;hp=24640f4a2c3923759ff3818acefb24a5dbaeb600;hpb=e10000740fc4c323dbc8d501d7c0caeae12c19b5;p=nfs-utils.git diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index 24640f4..3990578 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -251,17 +251,19 @@ conf_parse_line(int trans, char *line, size_t sz) } /* Strip off any blanks before ']' */ val = line; + j=0; while (*val && !isblank(*val)) val++, j++; if (*val) i = j; - section = malloc(i); + section = malloc(i+1); if (!section) { xlog_warn("conf_parse_line: %d: malloc (%lu) failed", ln, (unsigned long)i); return; } strncpy(section, line, i); + section[i] = '\0'; if (arg) free(arg); @@ -271,9 +273,9 @@ conf_parse_line(int trans, char *line, size_t sz) if (ptr == NULL) return; line = ++ptr; - while (*ptr && *ptr != '"') + while (*ptr && *ptr != '"' && *ptr != ']') ptr++; - if (*ptr == '\0') { + if (*ptr == '\0' || *ptr == ']') { xlog_warn("config file error: line %d: " "non-matched '\"', ignoring until next section", ln); } else {