mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 15:28:07 +02:00
tools: fix swapped fread arguments causing DMI modalias to always be "unknown"
fread(buf, sizeof(buf), 1, dmi) reads one block of 2048 bytes, returning the number of complete blocks (0 or 1). Since DMI modalias files are always shorter than 2048 bytes, fread returns 0 even when data was successfully read into buf. The 'if (n > 0)' check then always fails and the DMI string stays as "unknown". Swap the size and nmemb arguments so fread returns the number of bytes read instead. Fixes:0ecd08c134("tools: use __attribute__(cleanup)") Co-Authored-by: Claude Code <noreply@anthropic.com> (cherry picked from commitc8c1c07a2a) Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1468>
This commit is contained in:
parent
5ce952eb25
commit
5be0a16dd0
1 changed files with 1 additions and 1 deletions
|
|
@ -1404,7 +1404,7 @@ print_system_header(FILE *fp)
|
|||
_autofree_ char *dmistr = strdup("unknown"); //
|
||||
if (dmi) {
|
||||
char buf[2048] = "unknown";
|
||||
size_t n = fread(buf, sizeof(buf), 1, dmi); // NOLINT: unix.Stream
|
||||
size_t n = fread(buf, 1, sizeof(buf), dmi); // NOLINT: unix.Stream
|
||||
if (n > 0) {
|
||||
free(dmistr);
|
||||
dmistr = strndup(buf, n - 1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue