[PATCH] Avoid NULL dereference in FileDevicePathFromConfig

3 views
Skip to first unread message

Christian Storm

unread,
Aug 16, 2021, 3:00:42 AM8/16/21
to efibootg...@googlegroups.com, Christian Storm
From: Christian Storm <christi...@siemens.com>

StrnCmp() dereferences both its CHAR16 pointer arguments.
If src is NULL which happens in the default case and if,
e.g., a CUSTOMLABEL is absent, StrnCmp() dereferences a
NULL pointer. Avoid this by calling StrnCmp() only if
src != NULL.

This is no change in behavior as devpath would not have
been set anyway.

Signed-off-by: Christian Storm <christi...@siemens.com>
---
utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index ba9239b..44c2dac 100644
--- a/utils.c
+++ b/utils.c
@@ -245,7 +245,7 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
src = NULL;
break;
}
- if (StrnCmp(src, &payloadpath[2], prefixlen) == 0) {
+ if (src && (StrnCmp(src, &payloadpath[2], prefixlen) == 0)) {
devpath = volumes[v].devpath;
break;
}
--
2.32.0

Jan Kiszka

unread,
Aug 16, 2021, 3:53:11 AM8/16/21
to Christian Storm, efibootg...@googlegroups.com
Thanks, applied.

Jan

--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages