summaryrefslogtreecommitdiff
path: root/node/Utils.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-30 17:05:43 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-30 17:05:43 -0400
commitf3ad05347e55de2fd2a500464acde0979df9941f (patch)
tree57376b3114e193201dcfe2d08ef2a5bdb693ad30 /node/Utils.hpp
parent1a7e303f97507842c1a0bfffb27b76277bd43bab (diff)
downloadinfinitytier-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.hpp12
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