c++ - How to get rid of insecure functions (sprintf, ...) -
i want rid of uses of insecure functions sprintf
, in large c++ project. have errors or @ least warnings
, show me occurrences further reviewing. know, on openbsd there such warning, i'm on linux. if try define macro sprintf
errors in <cstdio>
header. ideas, besides patching system headers?
edit: additional challenge is, there sprintf function in homegrown c++ string class. so, grepping sprintf results in lot of false positives.
even though concurr @matt functions not bad, , quite indiscriminate in banning, here ways so.
today patch headers day:
- copy headers, run grep find functions fear.
- add
__attribute__ ((deprecated))
them. - recompile project.
- profit???
not patching headers?
still, might better go direct way: grep own project files.
can save search script re-application.use preprocessor (beware, changing reserved identifiers, bad!):
add file "explosive_security.h" this:
inline static int my_deprecated() __attribute__ ((deprecated)) {return 0;} #undef strcmp #define strcmp (my_deprecated(), strcmp)
and include after other includes.
should generate warning , no error in contexts, though error in some.
Comments
Post a Comment