vm: bound trace data printing#10301
Open
fallintoplace wants to merge 2 commits into
Open
Conversation
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/flamenco/vm/fd_vm_trace.c
Line: 11-15
Comment:
**Missing format attribute for compile-time checking**
`fd_cstr_append_printf` in this codebase declares `__attribute__((format(printf,2,3)))` to enable compile-time format string validation (see `fd_cstr.h:240`). This new variadic helper should do the same to catch format/argument mismatches at compile time.
```suggestion
static int
fd_vm_trace_printf_append( char ** p,
char * end,
char const * fmt,
... ) __attribute__((format(printf,3,4)));
static int
fd_vm_trace_printf_append( char ** p,
char * end,
char const * fmt,
... ) {
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "vm: bound trace data printing" | Re-trigger Greptile |
Comment on lines
+11
to
+15
| static int | ||
| fd_vm_trace_printf_append( char ** p, | ||
| char * end, | ||
| char const * fmt, | ||
| ... ) { |
There was a problem hiding this comment.
Missing format attribute for compile-time checking
fd_cstr_append_printf in this codebase declares __attribute__((format(printf,2,3))) to enable compile-time format string validation (see fd_cstr.h:240). This new variadic helper should do the same to catch format/argument mismatches at compile time.
Suggested change
| static int | |
| fd_vm_trace_printf_append( char ** p, | |
| char * end, | |
| char const * fmt, | |
| ... ) { | |
| static int | |
| fd_vm_trace_printf_append( char ** p, | |
| char * end, | |
| char const * fmt, | |
| ... ) __attribute__((format(printf,3,4))); | |
| static int | |
| fd_vm_trace_printf_append( char ** p, | |
| char * end, | |
| char const * fmt, | |
| ... ) { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/flamenco/vm/fd_vm_trace.c
Line: 11-15
Comment:
**Missing format attribute for compile-time checking**
`fd_cstr_append_printf` in this codebase declares `__attribute__((format(printf,2,3)))` to enable compile-time format string validation (see `fd_cstr.h:240`). This new variadic helper should do the same to catch format/argument mismatches at compile time.
```suggestion
static int
fd_vm_trace_printf_append( char ** p,
char * end,
char const * fmt,
... ) __attribute__((format(printf,3,4)));
static int
fd_vm_trace_printf_append( char ** p,
char * end,
char const * fmt,
... ) {
```
How can I resolve this? If you propose a fix, please make it concise.|
Reviews (2): Last reviewed commit: "vm: add trace printf format checking" | Re-trigger Greptile |
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.
Summary
vsnprintf-backed helpersevent_data_maxgreater than 2048Root cause
fd_vm_trace_printf()sized its stack buffer for 2048 printable data bytes, butdata_szcame fromtrace->event_data_max. A larger trace data cap let the memory dump loop write past the buffer through unboundedfd_cstr_append_printf()/vsprintfcalls.Validation
git diff --checkclang -std=c17 -fsyntax-only -I. -D_XOPEN_SOURCE=700 -DFD_HAS_HOSTED=1 -DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 src/flamenco/vm/fd_vm_trace.cclang -std=c17 -fsyntax-only -I. -D_XOPEN_SOURCE=700 -DFD_HAS_HOSTED=1 -DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 src/flamenco/vm/test_vm_base.cCould not run
gmake -j test_vm_baselocally on macOS: the native make path hits BSDgrep -Pand does not expose atest_vm_basetarget in this environment.