Commit c31c795
authored
fix(security): resolve CodeQL SM02986 char*/wchar_t* cast warnings (#1602)
Fixes 10 instances of CodeQL security finding SM02986 ('Cast from
char* to wchar_t*') across three shared source files.
Changes:
- core_util.cpp: Use intermediate SQLWCHAR* variable in
convert_string_from_utf16_inplace to avoid inline cast; add
clarifying comments for two void*->SQLWCHAR* malloc casts.
- core_stream.cpp: Extract single LPCWSTR intermediate variable before
#ifdef branches in sqlsrv_stream_read (CP_UTF8 path) with comment
explaining ODBC fills the buffer as SQL_C_WCHAR even though allocated
as char*.
- core_stmt.cpp: Remove redundant reinterpret_cast in
convert_input_str_to_utf16 (str is already char*); add typed
intermediate variable for SQLPOINTER buffer cast in
process_string_param; add typed intermediate for SQLWCHAR* cast in
process_output_string; add clarifying comments for intentional
SQLWCHAR*->char* binary storage casts.
No behavioral changes. All casts are semantically correct; changes
improve readability and satisfy the static analysis rule.
Verified: BUILD_EXIT_CODE=0 for both sqlsrv and pdo_sqlsrv extensions
against PHP 8.4.14 (VS2022 x64 ZTS).1 parent 9e82915 commit c31c795
3 files changed
Lines changed: 25 additions & 6 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2309 | 2309 | | |
2310 | 2310 | | |
2311 | 2311 | | |
2312 | | - | |
| 2312 | + | |
| 2313 | + | |
2313 | 2314 | | |
2314 | 2315 | | |
2315 | 2316 | | |
2316 | 2317 | | |
| 2318 | + | |
| 2319 | + | |
2317 | 2320 | | |
2318 | 2321 | | |
2319 | 2322 | | |
| |||
2747 | 2750 | | |
2748 | 2751 | | |
2749 | 2752 | | |
2750 | | - | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
2751 | 2756 | | |
2752 | 2757 | | |
2753 | 2758 | | |
2754 | 2759 | | |
| 2760 | + | |
| 2761 | + | |
2755 | 2762 | | |
2756 | 2763 | | |
2757 | 2764 | | |
| |||
2904 | 2911 | | |
2905 | 2912 | | |
2906 | 2913 | | |
2907 | | - | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
2908 | 2918 | | |
2909 | 2919 | | |
2910 | 2920 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
203 | 207 | | |
204 | | - | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | | - | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
| |||
202 | 205 | | |
203 | 206 | | |
204 | 207 | | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
| |||
318 | 322 | | |
319 | 323 | | |
320 | 324 | | |
| 325 | + | |
321 | 326 | | |
322 | 327 | | |
323 | 328 | | |
| |||
0 commit comments