Commit f0c34f1
Fix TSA #2816216: suppress Flawfinder false positive on Cython DIGIT_PAIRS_8 memcpy (#2028)
* Fix TSA #2816216: suppress Flawfinder false positive on Cython DIGIT_PAIRS_8 memcpy
Flawfinder's buffer/memcpy rule (CWE-120) fires on any memcpy() call by
default. The flagged call sits inside the Cython 3.x integer formatter
__Pyx____Pyx_PyUnicode_From_int (case 'o'):
memcpy(dpos, DIGIT_PAIRS_8 + digit_pos * 2, 2);
It is provably safe:
* dpos points into the stack buffer `digits[sizeof(int)*3+2]` (14 bytes
for a 32-bit int); `dpos -= 2` immediately precedes the copy and the
enclosing do/while loop iterates at most ceil(log_64(max_int)) times,
so dpos always stays >= digits.
* DIGIT_PAIRS_8 is a 128-byte compile-time constant table containing the
64 two-character octal digit pairs "00".."77". `digit_pos = abs(remaining
% 64)`, so `digit_pos * 2` ranges over [0, 126] and reads 2 bytes from
offset [0, 127] -- within the table.
* The size argument is the compile-time constant 2.
Add an inline /* Flawfinder: ignore */ annotation on the flagged line in
the Cython-generated pydevd_cython.c and extend the existing
post-processing block in setup_pydevd_cython.py so the annotation is
re-applied automatically whenever Cython regenerates the .c files.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix SyntaxError: add missing closing paren on DIGIT_PAIRS_8 .replace() call
Same merge-from-main artifact as #2029: the closing ')' of the new
DIGIT_PAIRS_8 '.replace(...)' call was dropped when the 'read<end'
'.replace(...)' block was spliced in, leaving the second call's args
being parsed as continued positional args to the first.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4c70e13 commit f0c34f1
2 files changed
Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
180 | 190 | | |
181 | 191 | | |
182 | 192 | | |
| |||
0 commit comments