Policy Update: disallow unsafe string manipulation functions

There has been a new section added to the developers best practices page stating unsafe string manipulation functions should be avoided: Style Guide/Best Practice C Cpp - Blender Developer Wiki

A more detailed rationale can be found in the proposal: #108917 - Policy: disallow unsafe string manipulation functions - blender - Blender Projects


For some background: previously we accepted use of string manipulation functions generally considered unsafe, strcpy, sprintf … etc, even though Blender defined safe alternatives with the assumption that developers know that they’re doing and can avoid the risks by being careful.
Having checked use of unsafe functions I found this isn’t the case - with enough usage not properly accounting for buffer overflows. It was agreed to disallow use of these functions.

With very few exceptions their use has now been removed from source/ and much of intern/.

Unfortunately there doesn’t seem to be any portable methods of poisoning these functions (so their use results in build errors), so this needs to be enforced manually & code-review.

For anyone who doubts Blender developers would make such schoolboy errors, here’s a shortened list of issues:

8 Likes