dell / libsmbios

library for interacting with Dell SMBIOS tables
Other
190 stars 39 forks source link

Improve error handling in libsmbios #32

Closed kholia closed 6 years ago

kholia commented 6 years ago

I am using libsmbios 2.3.3. The smbios-get-ut-data utility crashes when run as a normal user.

$ smbios-get-ut-data  # normal user
Libsmbios:    2.3.3
Segmentation fault (core dumped)

It would be nice to check if the user has the required privilege level, and exit gracefully if that is not the case.

$ sudo smbios-get-ut-data  # as root
Libsmbios:    2.3.3
dumping table header.
dumping table.
dumped table.
table length: 519
superm1 commented 6 years ago

Can you please check with master? I believe this was actually a different problem causing that segfault that was fixed.

kholia commented 6 years ago

With master,

$ git rev-parse HEAD
4fec2add58830d6c580ac3aab1323848a43e8c6b

$ ./out/smbios-get-ut-data
Libsmbios:    2.3.3
Segmentation fault (core dumped)
superm1 commented 6 years ago

Can you give that branch I just submitted a try? I think that should sort out the problems with this one.

kholia commented 6 years ago

The wip/fix-32 branch works quite well :+1:

$ ./out/smbios-get-ut-data 
Libsmbios:    2.3.3
error initializing SMBIOS table
could not read from memory: Permission denied
could not read from memory: Permission denied
$ git rev-parse HEAD
63396cb5770e2790d270609f6876a8c4fb6a0c84
$ sudo ./out/smbios-get-ut-data 
Libsmbios:    2.3.3
dumping table header.
dumping table.
dumped table.
table length: 3291
kholia commented 6 years ago

I recently scanned libsmbios 2.3.3 using Coverity, and I am attaching the report here.

libsmbios-coverity-scan-results.txt (scan results).

Some of the Coverity findings in this particular report are false positives, so please ignore them. I believe that this report can help in improving (and possibly hardening) libsmbios.

superm1 commented 6 years ago

Thanks for sharing. Recently some work went into master from a coverity scan. It should be fairly better. I've been meaning to rescan.

superm1 commented 6 years ago

I merged fixes-32 today.