aboutsummaryrefslogtreecommitdiff
path: root/toys/other/lspci.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-06-15 15:47:01 -0500
committerRob Landley <rob@landley.net>2016-06-15 15:47:01 -0500
commit46409d50e5632b28b88cfa4991fffef9adaa490d (patch)
tree4c3347b37664b580996e4551bde023346567728b /toys/other/lspci.c
parent97ddc600c95623bf803eac4f2a4deda2a2db02d4 (diff)
downloadtoybox-46409d50e5632b28b88cfa4991fffef9adaa490d.tar.gz
Add readlink0() and readlinkat0() which null terminate the data.
Diffstat (limited to 'toys/other/lspci.c')
-rw-r--r--toys/other/lspci.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/toys/other/lspci.c b/toys/other/lspci.c
index 077ce757..a0671791 100644
--- a/toys/other/lspci.c
+++ b/toys/other/lspci.c
@@ -50,10 +50,9 @@ static int do_lspci(struct dirtree *new)
if (-1 == (dirfd = openat(dirtree_parentfd(new), new->name, O_RDONLY)))
return 0;
- // it's ok for the driver link not to be there, whatever fortify says
*driver = 0;
if (toys.optflags & FLAG_k)
- if (readlinkat(dirfd, "driver", driver, sizeof(driver))) {};
+ readlinkat0(dirfd, "driver", driver, sizeof(driver));
for (fields = (char*[]){"class", "vendor", "device", 0}; *fields; fields++) {
int fd, size = 6 + 2*((toys.optflags & FLAG_e) && p == toybuf);
@@ -122,8 +121,7 @@ void lspci_main(void)
{
if (CFG_LSPCI_TEXT && TT.numeric != 1) {
if (!TT.ids) TT.ids = "/usr/share/misc/pci.ids";
- if (!(TT.db = fopen(TT.ids, "r")))
- perror_msg("could not open PCI ID db");
+ if (!(TT.db = fopen(TT.ids, "r"))) perror_msg("%s", TT.ids);
}
dirtree_read("/sys/bus/pci/devices", do_lspci);