All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] libkeymap: prevent NULL dereference in parser
@ 2026-02-14 17:27 Krdyan Areg
  2026-02-14 17:27 ` [PATCH 2/4] kbdfile: remove redundant NULL check in findfile_by_fullname Krdyan Areg
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Krdyan Areg @ 2026-02-14 17:27 UTC (permalink / raw)
  To: kbd; +Cc: gladkov.alexey, Krdyan Areg

The parser accesses ctx->key_line array elements without checking if
lk_array_get() returns NULL, which can lead to crashes.

Add NULL checks before dereferencing array values.

Signed-off-by: Krdyan Areg areg.krdian@gmail.com
---
 src/libkeymap/parser.y | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libkeymap/parser.y b/src/libkeymap/parser.y
index 2cd509f..a87fb54 100644
--- a/src/libkeymap/parser.y
+++ b/src/libkeymap/parser.y
@@ -320,6 +320,9 @@ singleline	: KEYCODE NUMBER EQUALS rvalue0 EOL
 
 							if (i < ctx->key_line->count) {
 								val = lk_array_get(ctx->key_line, i);
+								if (!val)
+									YYERROR;
+
 								keycode = *val;
 							}
 
@@ -338,7 +341,7 @@ singleline	: KEYCODE NUMBER EQUALS rvalue0 EOL
 					for (i = 0; i < ctx->key_line->count; i++) {
 						val = lk_array_get(ctx->key_line, i);
 
-						if (lk_add_key(ctx, i, $2, *val) < 0)
+						if (!val || lk_add_key(ctx, i, $2, *val) < 0)
 							YYERROR;
 					}
 				}
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-02-15 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 17:27 [PATCH 1/4] libkeymap: prevent NULL dereference in parser Krdyan Areg
2026-02-14 17:27 ` [PATCH 2/4] kbdfile: remove redundant NULL check in findfile_by_fullname Krdyan Areg
2026-02-14 17:27 ` [PATCH 3/4] libkeymap: add NULL check in kt_latin symbol lookup Krdyan Areg
2026-02-14 17:27 ` [PATCH 4/4] libkeymap: add NULL check in lk_dump_ctable diacritical loop Krdyan Areg
2026-02-14 23:08   ` Alexey Gladkov
2026-02-15  8:04     ` Areg Krdyan
2026-02-15 17:49       ` Alexey Gladkov
2026-02-15 17:34 ` [PATCH 1/4] libkeymap: prevent NULL dereference in parser Alexey Gladkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.