summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-27 06:26:23 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-27 06:26:23 +0000
commit22dc19b5908f73807e160c185156cb16a849049f (patch)
treec254cb9870af480e3f8e905f3dca088e7f67cfda /src/common/util.h
parent06fa8fc05fe36d7154e5c321a080607a21690808 (diff)
downloadtor-22dc19b5908f73807e160c185156cb16a849049f.tar.gz
tor-22dc19b5908f73807e160c185156cb16a849049f.zip
snprintf wrapper with consistant (though not C99) overflow behavior
svn:r2606
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h
index e4f0eaec55..f9f50f086e 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -13,6 +13,7 @@
#include "orconfig.h"
#include "torint.h"
#include <stdio.h>
+#include <stdarg.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@@ -106,7 +107,18 @@ long tor_parse_long(const char *s, int base, long min,
unsigned long tor_parse_ulong(const char *s, int base, unsigned long min,
unsigned long max, int *ok, char **next);
+/* XXXX duplicated from log.h */
+#ifdef __GNUC__
+#define CHECK_PRINTF(formatIdx, firstArg) \
+ __attribute__ ((format (printf, formatIdx, firstArg)))
+#else
+#define CHECK_PRINTF(formatIdx, firstArg)
+#endif
+int tor_snprintf(char *str, size_t size, const char *format, ...)
+ CHECK_PRINTF(3,4);
+int tor_vsnprintf(char *str, size_t size, const char *format, va_list args);
+
/* Some platforms segfault when you try to access a multi-byte type
* that isn't aligned to a word boundary. The macros and/or functions
* below can be used to access unaligned data on any platform.