From 92a2f084fb91d9613eafcad8f5e4a7238155717e Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Thu, 12 Mar 2026 14:59:40 +0800
Subject: [PATCH] Fix stop event check crash for grub-command

When skipping the leading operators in grub-command, the ending '\0'
wasn't checked and this may make the loop continue and access the memory
beyond the string.

Fix the potential crash by adding the check for '\0'.

Signed-off-by: Gary Lin <glin@suse.com>
---
 src/oracle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/oracle.c b/src/oracle.c
index 32aba76..ec635b2 100644
--- a/src/oracle.c
+++ b/src/oracle.c
@@ -444,7 +444,7 @@ __check_stop_event(tpm_event_t *ev, int type, const char *value, tpm_event_log_s
 			return false;
 
 		grub_cmd = grub_arg;
-		while (grub_cmd != NULL && !isalpha(*grub_cmd))
+		while (grub_cmd != NULL && *grub_cmd != '\0' && !isalpha(*grub_cmd))
 			grub_cmd++;
 
 		return !strcmp(grub_cmd, value);
-- 
2.51.0

