Hi! First time here, so my apologies if I'm violating some spoken or unspoken 
rules :)

I'm developing/maintaining two specialized storage engines(*) and I have one 
issue:

There are numerous uses of sprintf() in the general mariadb codebase, and each 
one generates a warning during compilation when doing a plain cmake/make build 
(on MacOS & RHEL7 at least).

I am a bit fanatical about hunting down and eliminating warnings if at all 
possible, no matter how small and insignificant - if you become accustomed to 
routinely getting warnings during compilation, you can easily overlook an 
important one.

So I am considering to contribute with a patch that will eliminate all 
sprintf() instances by converting them to snprintf(destination, N, ...). Of 
course, hunting down the correct N for each instance can be a *lot* of work (I 
presume this is why this hasn't been done already). So I'm proposing to make a 
macro UNSAFE_SNPRINTF(destination, ...) which would expand to 
snprintf(destination, 10000, ...) and replace all current sprintf() calls with 
that.

Yes, 10000 is a ridiculously high number that makes it look like we're 
introducing a huge security risk, but but the current sprintf() calls have an 
implicit N = infinity.

In some instances, the compiler sniffs out the actual size of the buffer and 
complains - in that case I would change the code to an appropriate regular 
snprintf() call.

Would doing this be worthwile? I.e., is there a good chance that such a patch 
would actually be accepted into the codebase?

If so, I might also do the same with other warnings (I believe there are some 
type-punning warnings at least).

Sincerely,
Stein Haugan

*) The engines are for internal use so far, but might make them public at some 
point
_______________________________________________
developers mailing list -- developers@lists.mariadb.org
To unsubscribe send an email to developers-le...@lists.mariadb.org

Reply via email to