Commit
e01765d30b7c4767868d5379fbfb36d1dc15eba4 added is_deprecated(), which
crashed when user had input without without /proc/sys/ subdirectory. The below
should illustrate how exactly the bug got to be trickered.
$ cat ~/foo
cause = crash
$ ./sysctl -p ~/foo
Segmentation fault
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
const char *equals;
char *tmpname;
char *outname;
+ char *last_dot;
+
FILE *fp;
struct stat ts;
outname[equals - name] = 0;
/* change / to . */
slashdot(outname, '/', '.');
- if(is_deprecated(strrchr(outname, '.') + 1)) {
+ last_dot = strrchr(outname, '.');
+ if (last_dot != NULL && is_deprecated(last_dot + 1)) {
xwarnx(_("%s is deprecated, value not set"), outname);
goto out;
}