[MDEV-22545] my_vsnprintf behaves not as in C standard Created: 2020-05-13  Updated: 2020-10-06  Resolved: 2020-06-04

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.2.32, 10.3.23, 10.4.13, 10.5.3
Fix Version/s: 10.5.4, 10.2.35, 10.3.24, 10.4.14

Type: Bug Priority: Blocker
Reporter: Sergei Golubchik Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-20604 Duplicate key value is silently trunc... Closed
Relates
relates to MDEV-21978 make my_vsnprintf to use gcc-compatib... Open
relates to MDEV-22147 main.mysqldump fails with wrong resul... Closed

 Description   

Some developers apparently don't like that now my_vsnprintf("%.*s") behaves not as in the C standard.

So, we'll change it back and introduce %S to print the truncation indicator.

All %s that print something to the end user have to be changed, for example, to %S. This includes all error messages and everything in the code too.

Don't forget to update the documentation in the service header file.

And we'll need some way to ensure that in the future all new printfs to the use also use %S.



 Comments   
Comment by Vladislav Vaintroub [ 2020-05-13 ]

Please, do not use %S , this is confusing. %S It is there to print wide strings, i.e wchar_t *

Even on Linux, and it is documented.

Comment by Vladislav Vaintroub [ 2020-05-15 ]

Maybe this can change, for example, to %sT , where T stands for truncated. And yes, the output will be different from whatever standard says, but it does not use either new unknown format specifiers, nor does it hijack the already known and documented ones, and it is still compatible with string, so you can use _attribute(format) on that.

Comment by Sergei Golubchik [ 2020-05-15 ]

yes, %sT, but that's after MDEV-21978. Depends on what's implemented first.

Comment by Marko Mäkelä [ 2020-05-19 ]

As far as I understand, the regression was introduced in MDEV-20604.

Comment by Marko Mäkelä [ 2020-05-26 ]

Sorry, I needed 2 after-merge fixes on 10.4. For the first one, my Windows build had failed without me noticing it, and that is why the %s→%T change was not reflected in the result file.

Generated at Thu Feb 08 09:15:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.