Skip to content

Commit

Permalink
zipl: NUL terminate buffer we're searching
Browse files Browse the repository at this point in the history
Found by a static analyzer.
  • Loading branch information
cgwalters committed Dec 14, 2023
1 parent e9a2a2c commit 241597a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libostree/ostree-bootloader-zipl.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ _ostree_secure_boot_is_enabled (gboolean *out_enabled, GCancellable *cancellable
while (*out_enabled != TRUE && max_lines > 0)
{
char buf[1024];
ssize_t len = TEMP_FAILURE_RETRY (read (fd, buf, sizeof (buf)));
ssize_t len = TEMP_FAILURE_RETRY (read (fd, buf, sizeof (buf) - 1));
if (len < 0)
break;
buf[len] = '\0';
*out_enabled = strstr (buf, "Secure-IPL enabled") != NULL;
--max_lines;
}
Expand Down

0 comments on commit 241597a

Please sign in to comment.