libfprint-CS9711
libfprint-CS9711 copied to clipboard
Thanks for your work! And some Security Vulnerability in source code, found by AI
The driver works on ubuntu 26.04 and 24.06 with latest kernel, thanks!
Here are 3 memory safety issues found by the AI review; I think they’re worth reading:
2. Security Vulnerability Analysis
🟡 Low Risk — Memory Safety
| # | Issue | File | Severity | Description |
|---|---|---|---|---|
| 1 | sigfm/binary.hpp:110 uses raw malloc() instead of new, while sigfm_free_info uses delete |
sigfm/binary.hpp:110 / sigfm/sigfm.cpp:208 |
Medium | malloc() + delete is undefined behavior (UB) and may cause heap corruption. Should consistently use either new[]/delete[] or g_malloc()/g_free(). |
| 2 | sigfm/binary.hpp copy_buffer() allocates with raw malloc and requires manual free() by the caller |
sigfm/binary.hpp:109-112 |
Low | Mixing raw malloc with GLib memory management conventions; potential for leaks at boundaries. |
| 3 | sigfm/sigfm.cpp:110 memcpy(img.data, pix, width * height) — no explicit bounds validation before copy |
sigfm/sigfm.cpp:110 |
Low | width * height could theoretically overflow, but cv::Mat::create() performs basic size validation before this point. |
Suggested Fix (Priority)
- Fix
malloc/deletemismatch insigfm/binary.hpp:110:- Option A: Replace
malloc(store_.size())withg_malloc(store_.size())and have the caller useg_free(). - Option B: Change
sigfm_free_info()to properlydelete[]or wrapSigfmImgInfoin a GObject with a proper finalizer.
- Option A: Replace
here is a fix: https://github.com/kenzed/libfprint-CS9711 tested on ubuntu 24.04 6.17.0-35-generic