-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Fix some Coverity warnings and false alarms #120155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 6, 2024
Initialize variables in _tkinter.c to make static analyzers happy.
vstinner
added a commit
that referenced
this issue
Jun 6, 2024
Initialize variables in _tkinter.c to make static analyzers happy.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 7, 2024
Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 7, 2024
Don't use 'g' before it's being initialized: don't use the 'error' label if consts_dict_keys_inorder() failed. Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"". 7712| Py_XDECREF(consts); 7713| instr_sequence_fini(&optimized_instrs); 7714|-> _PyCfgBuilder_Fini(&g); 7715| return co; 7716| }
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 7, 2024
Don't use 'g' before it's being initialized: don't use the 'error' label if consts_dict_keys_inorder() failed. Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"". 7712| Py_XDECREF(consts); 7713| instr_sequence_fini(&optimized_instrs); 7714|-> _PyCfgBuilder_Fini(&g); 7715| return co; 7716| }
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 7, 2024
Declare the 'rv' at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv).
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 7, 2024
Declare the 'rv' at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286|
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 7, 2024
Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286|
vstinner
added a commit
that referenced
this issue
Jun 7, 2024
#120231) gh-120155: Fix optimize_and_assemble_code_unit() error handling Don't use 'g' before it's being initialized: don't use the 'error' label if consts_dict_keys_inorder() failed. Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"". 7712| Py_XDECREF(consts); 7713| instr_sequence_fini(&optimized_instrs); 7714|-> _PyCfgBuilder_Fini(&g); 7715| return co; 7716| }
vstinner
added a commit
that referenced
this issue
Jun 7, 2024
…0228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? # 272| assert(dest->ndim > 0 && src->ndim > 0); # 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && # 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && # 275| dest->strides[dest->ndim-1] == dest->itemsize && # 276| src->strides[src->ndim-1] == src->itemsize);
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 7, 2024
pythonGH-120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? GH- 272| assert(dest->ndim > 0 && src->ndim > 0); GH- 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && GH- 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && GH- 275| dest->strides[dest->ndim-1] == dest->itemsize && GH- 276| src->strides[src->ndim-1] == src->itemsize); (cherry picked from commit 90b7540) Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 7, 2024
pythonGH-120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? GH- 272| assert(dest->ndim > 0 && src->ndim > 0); GH- 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && GH- 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && GH- 275| dest->strides[dest->ndim-1] == dest->itemsize && GH- 276| src->strides[src->ndim-1] == src->itemsize); (cherry picked from commit 90b7540) Co-authored-by: Victor Stinner <vstinner@python.org>
This was referenced Jun 7, 2024
vstinner
added a commit
that referenced
this issue
Jun 7, 2024
…() (GH-120228) (#120238) gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (GH-120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? GH- 272| assert(dest->ndim > 0 && src->ndim > 0); GH- 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && GH- 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && GH- 275| dest->strides[dest->ndim-1] == dest->itemsize && GH- 276| src->strides[src->ndim-1] == src->itemsize); (cherry picked from commit 90b7540) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this issue
Jun 7, 2024
…() (GH-120228) (#120240) gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (GH-120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? GH- 272| assert(dest->ndim > 0 && src->ndim > 0); GH- 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && GH- 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && GH- 275| dest->strides[dest->ndim-1] == dest->itemsize && GH- 276| src->strides[src->ndim-1] == src->itemsize); (cherry picked from commit 90b7540) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this issue
Jun 10, 2024
Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286|
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 10, 2024
…-120232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286| (cherry picked from commit b90bd3e) Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 10, 2024
…-120232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286| (cherry picked from commit b90bd3e) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this issue
Jun 10, 2024
…) (#120311) gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286| (cherry picked from commit b90bd3e) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this issue
Jun 10, 2024
…) (#120310) gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286| (cherry picked from commit b90bd3e) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 12, 2024
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 12, 2024
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 25, 2024
Add an assertion to make sure that the 'len' variable is at least 1, to make sure that '--len' above is safe. Fix the Coverity issue on Python-3.12.2: Error: INTEGER_OVERFLOW (CWE-190): Parser/string_parser.c:236:5: underflow: The decrement operator on the unsigned variable ""len"" might result in an underflow. Parser/string_parser.c:246:9: overflow: The expression ""len -= 2UL"" is deemed underflowed because at least one of its arguments has underflowed. Parser/string_parser.c:269:13: overflow_sink: ""len"", which might have underflowed, is passed to ""PyBytes_FromStringAndSize(s, len)"". 267| } 268| if (rawmode) { 269|-> return PyBytes_FromStringAndSize(s, len); 270| } 271| return decode_bytes_with_escapes(p, s, len, t);
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 25, 2024
Add an assertion to make sure that the 'len' variable is at least 1, to make sure that '--len' below is safe. Fix the Coverity issue on Python-3.12.2: Error: INTEGER_OVERFLOW (CWE-190): Parser/string_parser.c:236:5: underflow: The decrement operator on the unsigned variable ""len"" might result in an underflow. Parser/string_parser.c:246:9: overflow: The expression ""len -= 2UL"" is deemed underflowed because at least one of its arguments has underflowed. Parser/string_parser.c:269:13: overflow_sink: ""len"", which might have underflowed, is passed to ""PyBytes_FromStringAndSize(s, len)"". 267| } 268| if (rawmode) { 269|-> return PyBytes_FromStringAndSize(s, len); 270| } 271| return decode_bytes_with_escapes(p, s, len, t);
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 25, 2024
Add an assertion to make sure that the 'len' variable is at least 1, to make sure that the code '--len' below is safe. Fix the Coverity issue on Python-3.12.2: Error: INTEGER_OVERFLOW (CWE-190): Parser/string_parser.c:236:5: underflow: The decrement operator on the unsigned variable "len" might result in an underflow. Parser/string_parser.c:246:9: overflow: The expression "len -= 2UL" is deemed underflowed because at least one of its arguments has underflowed. Parser/string_parser.c:269:13: overflow_sink: "len", which might have underflowed, is passed to "PyBytes_FromStringAndSize(s, len)". 267| } 268| if (rawmode) { 269|-> return PyBytes_FromStringAndSize(s, len); 270| } 271| return decode_bytes_with_escapes(p, s, len, t);
pablogsal
pushed a commit
that referenced
this issue
Jun 25, 2024
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 25, 2024
(cherry picked from commit 769aea3) Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 25, 2024
(cherry picked from commit 769aea3) Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
added a commit
that referenced
this issue
Jun 25, 2024
vstinner
added a commit
that referenced
this issue
Jun 25, 2024
Ok, I'm done with the report with the report I was working on. I close the issue. |
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
…20232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286|
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
Initialize variables in _tkinter.c to make static analyzers happy.
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
python#120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? # 272| assert(dest->ndim > 0 && src->ndim > 0); # 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && # 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && # 275| dest->strides[dest->ndim-1] == dest->itemsize && # 276| src->strides[src->ndim-1] == src->itemsize);
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
…20232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286|
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
Initialize variables in _tkinter.c to make static analyzers happy.
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
python#120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? # 272| assert(dest->ndim > 0 && src->ndim > 0); # 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && # 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && # 275| dest->strides[dest->ndim-1] == dest->itemsize && # 276| src->strides[src->ndim-1] == src->itemsize);
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
…20232) Declare the 'rv' varaible at the top of the load_data() function to make sure that it's initialized before the first 'goto error' which uses 'rv' (return rv). Fix the Coverity issue: Error: UNINIT (CWE-457): Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"". Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"". 1282| } 1283| 1284|-> return rv; 1285| } 1286|
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got access to a Coverity scan of Python 3.12.2 and there are about 67 warnings. Most of them seem to be false alarms, my team is still investigating the warnings.
I propose to make minor changes, when it makes sense, to make some false alarms quiet.
And propose fixes for real issues :-)
Linked PRs
The text was updated successfully, but these errors were encountered: