Thread (2 messages) 2 messages, 2 authors, 2021-05-20

[libgpiod] segfaults in gpiodetect and gpioinfo

From: Frank Zago <frank@zago.net>
Date: 2021-05-20 02:59:37

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help