sqlite: check null returns from sqlite value functions - #63288
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63288 +/- ##
==========================================
- Coverage 90.30% 90.29% -0.01%
==========================================
Files 759 759
Lines 247754 247754
Branches 46716 46720 +4
==========================================
- Hits 223724 223719 -5
- Misses 15483 15512 +29
+ Partials 8547 8523 -24
🚀 New features to boost your workflow:
|
|
@ndossche Can you please rebase and force push? |
sqlite3_column_text() can return nullptr on failure which was not handled. sqlite3_column_blob() can return nullptr for zero-length BLOBs, which is then passed to memcpy() which is UB. Avoid this by checking for a nullptr. Signed-off-by: ndossche <nora.dossche@ugent.be>
|
Done, CI (so far) is looking okay |
|
Can you add some regression tests? Ones which fail in main, but succeed with the fix? |
Apparently the current test suite can already trigger the "UB blob" problem, but the test runner ignores UBSAN failures, so you never see this as a failure. As for the allocation failure in |
sqlite3_column_text() can return nullptr on failure which was not handled. sqlite3_column_blob() can return nullptr for zero-length BLOBs, which is then passed to memcpy() which is UB. Avoid this by checking for a nullptr.
Note: this was found by a static-dynamic analyser I'm developing.