diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-30 17:05:43 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-30 17:05:43 -0400 |
| commit | f3ad05347e55de2fd2a500464acde0979df9941f (patch) | |
| tree | 57376b3114e193201dcfe2d08ef2a5bdb693ad30 /node/Utils.hpp | |
| parent | 1a7e303f97507842c1a0bfffb27b76277bd43bab (diff) | |
| download | infinitytier-f3ad05347e55de2fd2a500464acde0979df9941f.tar.gz infinitytier-f3ad05347e55de2fd2a500464acde0979df9941f.zip | |
Improve code security posture by replacing sprintf with a safer function.
Diffstat (limited to 'node/Utils.hpp')
| -rw-r--r-- | node/Utils.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/node/Utils.hpp b/node/Utils.hpp index 8bced8ad..0d40e370 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -537,6 +537,18 @@ public: throw(std::bad_alloc,std::length_error); /** + * Variant of snprintf that is portable and throws an exception + * + * @param buf Buffer to write to + * @param len Length of buffer in bytes + * @param fmt Format string + * @param ... Format arguments + * @throws std::length_error buf[] too short (buf[] will still be left null-terminated) + */ + static unsigned int snprintf(char *buf,unsigned int len,const char *fmt,...) + throw(std::length_error); + + /** * Count the number of bits set in an integer * * @param v 32-bit integer |
