Ticket UUID: | abd489a1cf4782f0255f307c42370d3a5e27c464 | |||
Title: | TclStringCmp() calls functions through pointer to incorrect type | |||
Type: | Patch | Version: | 8.6.13 | |
Submitter: | chrstphrchvz | Created on: | 2023-10-13 07:20:01 | |
Subsystem: | 18. Commands M-Z | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2023-12-30 00:20:14 | |
Resolution: | Fixed | Closed By: | jan.nijtmans | |
Closed on: | 2023-12-30 00:20:14 | |||
Description: |
Example UBSan -fsanitize=function error:
% string compare a b
tcl/generic/tclCmdMZ.c:2863:10: runtime error: call to function TclpUtfNcmp2 through pointer to incorrect function type 'int (*)(const void *, const void *, unsigned long)'
tclUtf.c:1233: note: TclpUtfNcmp2 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/generic/tclCmdMZ.c:2863:10 in
-1
Some of the compare functions are public APIs, so I would suggest either using an enum to call functions directly, or wrapper functions (as done by the attached patch). | |||
User Comments: |
jan.nijtmans added on 2023-12-30 00:20:14:
This should be fixed in all branches now jan.nijtmans added on 2023-10-13 14:09:39: Thanks for the patch! Looks good. In this case, it's slightly better to do the wrapping slightly different: [6d9d5ac6a75d7832]. |
Attachments:
- abd489a1cf47.diff [download] added by chrstphrchvz on 2023-10-13 07:24:30. [details]