-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Description
Hello,
This might be a false positive, but running valgrind on a basic program like this:
#include <stdio.h>
#include <unistd.h>
#include <yara_x.h>
static const char rule[] = "rule test { condition: true }";
int main(void) {
YRX_COMPILER *compiler = NULL;
YRX_RESULT result = YRX_SUCCESS;
YRX_RULES *rules = NULL;
/* Create a compiler */
result = yrx_compiler_create(0, &compiler);
if (result != YRX_SUCCESS) {
printf("[YARA] Failed to create compiler: %s\n", yrx_last_error());
exit(1);
}
/* Add simple YARA rule */
result = yrx_compiler_add_source(compiler, rule);
if (result != YRX_SUCCESS) {
yrx_compiler_destroy(compiler);
printf("[YARA] Failed to create compiler: %s\n", yrx_last_error());
exit(1);
}
rules = yrx_compiler_build(compiler);
if (!rules) {
yrx_compiler_destroy(compiler);
printf("[YARA] Failed to build rules: %s\n", yrx_last_error());
exit(1);
}
yrx_compiler_destroy(compiler);
yrx_rules_destroy(rules);
return 0;
}
I compiled with:
cc -O2 -g -Wall -Wextra -W -Werror -lyara_x_capi a.cAnd executed valgrind with:
valgrind --tool=memcheck -s \
--show-leak-kinds=all \
--track-origins=yes \
--error-exitcode=1 \
--quiet \
./a.outReturns this output:
==10770== Conditional jump or move depends on uninitialised value(s)
==10770== at 0x5BDB652: wasmparser::parser::Parser::parse_reader (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x5BDC783: wasmparser::parser::Parser::parse (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x5AFC553: wasmtime_environ::compile::module_environ::ModuleEnvironment::translate (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x550465D: wasmtime::compile::build_artifacts (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x549F9FD: wasmtime::compile::runtime::<impl wasmtime::compile::code_builder::CodeBuilder>::compile_module (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x5506739: wasmtime::runtime::module::Module::from_binary (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x510A015: yara_x::compiler::Compiler::build (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x4EDFA99: yrx_compiler_build (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x400112B: main (a.c:29)
==10770== Uninitialised value was created by a stack allocation
==10770== at 0x5504538: wasmtime::compile::build_artifacts (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770==
==10770== ERROR SUMMARY: 6 errors from 1 contexts (suppressed: 0 from 0)
==10770==
==10770== 6 errors in context 1 of 1:
==10770== Conditional jump or move depends on uninitialised value(s)
==10770== at 0x5BDB652: wasmparser::parser::Parser::parse_reader (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x5BDC783: wasmparser::parser::Parser::parse (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x5AFC553: wasmtime_environ::compile::module_environ::ModuleEnvironment::translate (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x550465D: wasmtime::compile::build_artifacts (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x549F9FD: wasmtime::compile::runtime::<impl wasmtime::compile::code_builder::CodeBuilder>::compile_module (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x5506739: wasmtime::runtime::module::Module::from_binary (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x510A015: yara_x::compiler::Compiler::build (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x4EDFA99: yrx_compiler_build (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770== by 0x400112B: main (a.c:29)
==10770== Uninitialised value was created by a stack allocation
==10770== at 0x5504538: wasmtime::compile::build_artifacts (in /usr/local/lib/libyara_x_capi.so.1.10.0)
==10770==
==10770== ERROR SUMMARY: 6 errors from 1 contexts (suppressed: 0 from 0)
I built the library from the current main branch with cargo cinstall -p yara-x-capi --release
$ rustc --version
rustc 1.91.1 (ed61e7d7e 2025-11-07)
I am missing something on how to use the C API?
I leave the full track (--leak-check=full) valgrind.txt
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels