Repository navigation
logger: convert: refuse ldc format text that does not match its params - #11331
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
print_entry_params() hands the log text from the .ldc dictionary to fprintf() as the format string, with params_num trace words as the arguments. process_params() checks the text but only logs on a mismatch: with more conversion specifiers than params_num it prints "Too many % conversion specifiers" and fprintf() still runs with the full format, so every extra %s or %x reads a variadic argument that was never passed. The generic branch also forwards any specifier other than bare %s, %%, %pU and %pQ unchanged, so "%5s" or "%ls" dereferences the raw 32-bit trace word as a string pointer, a '*' width or precision consumes an extra argument and %n writes through a trace value. Return -EINVAL from process_params() for too many specifiers, a trailing '%', and '*', 'n' or modified 's' conversions, and print the entry text verbatim in that case. Skip "%%" before the parameter count check since it does not consume a parameter. Output for valid formats is unchanged. Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
Collaborator
|
Can one of the admins verify this patch?
|
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.
sof-logger hands the log text from the .ldc file to fprintf() as the format string, and process_params() only logs when that text does not fit the params:
name %5swith params_num = 1, orval %u then %swith params_num = 1, run withsof-logger -l t.ldc -i t.trace -nreproduces both under ASanprocess_params() now returns -EINVAL in those cases and the entry text is printed verbatim. "%%" is skipped before the param count check. Output for %d %u %x %08x %zu %lx %llu %f %pU %pQ %s %% is unchanged.