[MDEV-23942] mariadb-10.5.6/storage/connect/plugutil.cpp:380: bad width ? Created: 2020-10-08 Updated: 2020-12-12 Resolved: 2020-12-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Compiling, Storage Engine - Connect |
| Affects Version/s: | 10.5 |
| Fix Version/s: | 10.2.37, 10.3.28, 10.4.18, 10.5.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | David Binderman | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
mariadb-10.5.6/storage/connect/plugutil.cpp:380:7: error: Width 256 given in format string (no. 1) is larger than destination buffer 'msgid[32]', use %31s to prevent overflowing it. [invalidScanfFormatWidth] Source code is
|
| Comments |
| Comment by Anel Husakovic [ 2020-12-07 ] | |||||||||||||
|
Affected with 4d61f1247a1b
| |||||||||||||
| Comment by Anel Husakovic [ 2020-12-07 ] | |||||||||||||
|
Hi dcb thanks for the ticket. | |||||||||||||
| Comment by David Binderman [ 2020-12-07 ] | |||||||||||||
|
I used static analyser cppcheck on Fedora Linux to find this bug. | |||||||||||||
| Comment by Anel Husakovic [ 2020-12-07 ] | |||||||||||||
|
I have to test the patch which introduce this change to see why is applied, but looking man page for scanf and usage of format specifier %[*][width][length]specifier ,the optional width argument is allowed to have longer characters than the pointer, but we have to guarantee that it will not exceed the limits and the nonmatching character will be found before that.
Agree that it is best to check the valid length but will need to test also. | |||||||||||||
| Comment by Anel Husakovic [ 2020-12-07 ] | |||||||||||||
|
I run cppcheck for connect SE directory and got this also:
| |||||||||||||
| Comment by David Binderman [ 2020-12-07 ] | |||||||||||||
|
>[storage/connect/value.cpp:2519]: (error) Signed integer overflow for expression 'n*126230400'. If counting in chunks size about 126 million and ints only go to about two billion, Maybe #define FOURYEARS 126230400L // Four years in seconds (1 leap) or possibly: #define FOURYEARS ((long) (4 * 365.25 * 24 * 60 * 60)) | |||||||||||||
| Comment by Anel Husakovic [ 2020-12-10 ] | |||||||||||||
|
dcb you can create PR https://github.com/MariaDB/server/pulls to solve all from ^ | |||||||||||||
| Comment by David Binderman [ 2020-12-10 ] | |||||||||||||
|
Thanks for the offer to create a PR, but I will decline that one. I've reported a bug and pointed developers towards cppcheck. | |||||||||||||
| Comment by Sergei Golubchik [ 2020-12-10 ] | |||||||||||||
| Comment by David Binderman [ 2020-12-10 ] | |||||||||||||
|
Possible 2 * off by one error in commit. May I refer Sergei to the original message by cppcheck. 31 not 32 and probably 255, not 256. | |||||||||||||
| Comment by Sergei Golubchik [ 2020-12-10 ] | |||||||||||||
|
no problem, it wasn't pushed yet |