From 2cd7199d67842439504e26776efab88f719e6e41 Mon Sep 17 00:00:00 2001 From: Dwight Guth Date: Wed, 23 Aug 2023 13:23:47 -0500 Subject: [PATCH] fix bug in kore_block_get_bool (#830) We discovered a bug in the kore_block_get_bool function. It was reading 8 bytes and then casting the result to a bool, but a block containing a boolean as a child has one byte that is determined and 7 unspecified bytes that contain padding. As a result, if the padding was nonzero, the function would return true even if the injection actually contained the boolean `false`. This should fix that bug by casting the pointer to `bool*` before reading. --- bindings/c/lib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/c/lib.cpp b/bindings/c/lib.cpp index 1420a4bc3..dfc9ce810 100644 --- a/bindings/c/lib.cpp +++ b/bindings/c/lib.cpp @@ -268,7 +268,7 @@ kore_pattern *kore_pattern_from_block(block *term) { bool kore_block_get_bool(block *term) { assert((((uintptr_t)term) & 1) == 0); - return (bool)(term->children[0]); + return *(bool *)term->children; } bool kore_simplify_bool(kore_pattern const *pattern) {