mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-06-10 00:58:31 +02:00
tools: guard against zero-length os-release files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1467>
This commit is contained in:
parent
8afdc52eaf
commit
a5a9d2d8df
1 changed files with 3 additions and 1 deletions
|
|
@ -1379,7 +1379,9 @@ print_system_header(FILE *fp)
|
|||
char osrstr[256] = "unknown";
|
||||
|
||||
while (fgets(osrstr, sizeof(osrstr), osrelease)) {
|
||||
osrstr[strlen(osrstr) - 1] = '\0'; /* linebreak */
|
||||
size_t len = strlen(osrstr);
|
||||
if (len > 0 && osrstr[len - 1] == '\n')
|
||||
osrstr[len - 1] = '\0'; /* linebreak */
|
||||
|
||||
if (!distro && strstartswith(osrstr, "ID="))
|
||||
distro = strstrip(&osrstr[3], "\"'");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue