From: Frank Zago <frank@zago.net>
To: linux-gpio@vger.kernel.org
Subject: [libgpiod] segfaults in gpiodetect and gpioinfo
Date: Wed, 19 May 2021 21:59:32 -0500 [thread overview]
Message-ID: <b2cb3a3c-8e20-f733-9898-f8ba21b52f7d@zago.net> (raw)
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.
next reply other threads:[~2021-05-20 2:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 2:59 Frank Zago [this message]
2021-05-20 7:19 ` [libgpiod] segfaults in gpiodetect and gpioinfo Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b2cb3a3c-8e20-f733-9898-f8ba21b52f7d@zago.net \
--to=frank@zago.net \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.