Hello,
If a user doesn't have permission, both gpiodetect and gpioinfo
will segfault when run.
$ ./gpiodetect
gpiochip0 Permission denied
zsh: segmentation fault (core dumped) ./gpiodetect
The problem is there:
if (!chip) {
if (errno == EACCES)
printf("%s Permission denied\n",
entries[i]->d_name);
else
die_perror("unable to open %s",
entries[i]->d_name);
}
chip is NULL, but is later dereferenced.
I'm not submitting a fix as there are 2 possibilities that I can see,
and I don't know which one would be best:
- add a continue after the die_perror line
- replace the printf above with die_perror()
Regards,
Frank.