The current code would print the character following the first invalid
character.
Given an udev rules-file without a trailing newline we would otherwise print
garbage:
invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules
on line 26, starting at character 25 ('m')
This is now changed to print
invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules
on line 26, starting at character 25 ('')
(still not very good as printing \0 just gives the empty string)
/* If we aren't at the end of the line, this is a parsing error.
* Make a best effort to describe where the problem is. */
if (*linepos != '\n') {
/* If we aren't at the end of the line, this is a parsing error.
* Make a best effort to describe where the problem is. */
if (*linepos != '\n') {
- char buf[2] = {linepos[1]};
+ char buf[2] = {*linepos};
_cleanup_free_ char *tmp;
tmp = cescape(buf);
log_error("invalid key/value pair in file %s on line %u, starting at character %tu ('%s')",
filename, lineno, linepos - line + 1, tmp);
_cleanup_free_ char *tmp;
tmp = cescape(buf);
log_error("invalid key/value pair in file %s on line %u, starting at character %tu ('%s')",
filename, lineno, linepos - line + 1, tmp);
log_error("hint: comments can only start at beginning of line");
}
break;
log_error("hint: comments can only start at beginning of line");
}
break;