Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions c/lang/security/insecure-use-strtok-fn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ rules:
- id: insecure-use-strtok-fn
pattern: strtok(...)
message: >-
Avoid using 'strtok()'. This function directly modifies the first argument buffer,
permanently erasing the
delimiter character. Use 'strtok_r()' instead.
Avoid 'strtok()': it is not reentrant, and the C standard does not require it to
be thread-safe. It keeps the scan position in hidden static state, so interleaved
calls (even on unrelated strings) clobber each other. It also modifies its input
in place, replacing each token-ending delimiter with a NUL byte. Use the
reentrant 'strtok_r()' (POSIX) or 'strtok_s()' (C11 Annex K), which keep the scan
state in a caller-provided context.
metadata:
cwe:
- 'CWE-676: Use of Potentially Dangerous Function'
Expand Down