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.

  1. today patch headers day:

    1. copy headers, run grep find functions fear.
    2. add __attribute__ ((deprecated)) them.
    3. recompile project.
    4. profit???
  2. not patching headers?

    still, might better go direct way: grep own project files.
    can save search script re-application.

  3. 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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -