Skip to content

fix(c): improve insecure-use-strtok-fn message#3769

Open
MarkLee131 wants to merge 1 commit into
semgrep:developfrom
MarkLee131:fix/strtok-message
Open

fix(c): improve insecure-use-strtok-fn message#3769
MarkLee131 wants to merge 1 commit into
semgrep:developfrom
MarkLee131:fix/strtok-message

Conversation

@MarkLee131
Copy link
Copy Markdown

The current message says strtok "permanently erases the delimiter character", which is strtok's normal documented behavior, not a security issue.

So we updated the message to describe the actual risks:

  • Non-thread-safe internal static state (concurrent/nested calls corrupt parsing)
  • Input buffer mutation (secondary, but worth noting)
  • Recommends both strtok_r() (POSIX) and strtok_s() (C11) as alternatives

Found while scanning Vim (~400k LOC) with --config auto — all 21 strtok findings were false positives. The inaccurate message made triage harder since the stated risk wasn't the real concern.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 17, 2026

CLA assistant check
All committers have signed the CLA.

@MarkLee131
Copy link
Copy Markdown
Author

Bump on this...
Is anyone able to take a look? Just a message-text change, no rule logic touched.
@LewisArdern @0xDC0DE if either of you has a moment. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants