X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev_config.c;h=ba2b3d2b886966eaa890d09673e9a64a310e79c8;hb=a5e425369c9eccb35c7d0533e7a9dbdee864a6b5;hp=19f690c7e8cd0d77d703b7adfcec3fcebb534db6;hpb=c33359307b4a337d6c4f2f4fbe4451544fa5cc1f;p=elogind.git diff --git a/udev_config.c b/udev_config.c index 19f690c7e..ba2b3d2b8 100644 --- a/udev_config.c +++ b/udev_config.c @@ -127,7 +127,8 @@ int parse_get_pair(char **orig_string, char **left, char **right) static int parse_config_file(void) { - char line[255]; + char line[LINE_SIZE]; + char *bufline; char *temp; char *variable; char *value; @@ -148,32 +149,35 @@ static int parse_config_file(void) /* loop through the whole file */ lineno = 0; cur = 0; - while (1) { + while (cur < bufsize) { count = buf_get_line(buf, bufsize, cur); - - strncpy(line, buf + cur, count); - line[count] = '\0'; - temp = line; - lineno++; - + bufline = &buf[cur]; cur += count+1; - if (cur > bufsize) - break; - - dbg_parse("read '%s'", temp); + lineno++; - /* eat the whitespace at the beginning of the line */ - while (isspace(*temp)) - ++temp; + if (count >= LINE_SIZE) { + info("line too long, conf line skipped %s, line %d", + udev_config_filename, lineno); + continue; + } - /* empty line? */ - if (*temp == 0x00) + /* eat the whitespace */ + while ((count > 0) && isspace(bufline[0])) { + bufline++; + count--; + } + if (count == 0) continue; /* see if this is a comment */ - if (*temp == COMMENT_CHARACTER) + if (bufline[0] == COMMENT_CHARACTER) continue; + strncpy(line, bufline, count); + line[count] = '\0'; + temp = line; + dbg_parse("read '%s'", temp); + retval = parse_get_pair(&temp, &variable, &value); if (retval != 0) info("%s:%d:%Zd: error parsing '%s'",