review and refactor c code for simplicity and security#1175
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
High priority findings
zen_io.c:177. Those branches should return immediately after the error instead of continuing into memcpy.
zencode-exec.c:61, so it needs +1. The config path also appends ",logfmt=json" with strcat() in src/zencode-exec.c:123 after a truncation check in src/zencode-
exec.c:114 that can never catch a too-long fgets() result.
sprintf() unnecessarily. This is an over-read/overflow risk and also misparses embedded NULs and ASN.1 long-form lengths.
ownership behind global singletons and macro-redefined malloc/free. That hurts readability, makes the VM non-reentrant, and complicates maintenance.
zen_error.c:185 return early without va_end(). NULL-context logging is therefore undefined behavior today.
headers fall into the error path.
src/zenroom.c:232 does not check RNG allocation, and src/zenroom.c:288 can return after Lua state creation without lua_close().
that reduced bound in src/zen_config.c:131. The copy at src/zen_config.c:140 still takes the full payload.
makes the helper misleading.
bits still reports 1 byte.
bytes with strncat().
zen_longfellow.c:147, and the direct const char * calls at src/zen_longfellow.c:271 and src/zen_longfellow.c:345. This boundary needs explicit length checks
and NUL-terminated staging buffers.
freed at src/api_hash.c:210.
shared state point.
Lower-Priority Cleanup
especially clear or efficient.