D.5 Security-conscious coding
PuTTY is a network application and a security application. Assume your code will end up being fed deliberately malicious data by attackers, and try to code in a way that makes it unlikely to be a security risk.
In particular, try not to use fixed-size buffers for variable-size data such as strings received from the network (or even the user). We provide functions such as dupcat
and dupprintf
, which dynamically allocate buffers of the right size for the string they construct. Use these wherever possible.