Skip to content

Commit

Permalink
fix bug in kore_block_get_bool (#830)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dwight Guth authored Aug 23, 2023
1 parent 9bcd113 commit 2cd7199
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bindings/c/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2cd7199

Please sign in to comment.