[tor-commits] [tor/master] Fix an instance of snprintf; don't use _snprintf directly

nickm at torproject.org nickm at torproject.org
Thu Jan 17 03:32:41 UTC 2013


commit b7cf7bd9ae31aeddd03ad2094dd480d2b1d34d4f
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Dec 19 16:51:53 2012 -0500

    Fix an instance of snprintf; don't use _snprintf directly
---
 changes/7304         |    7 +++++++
 src/common/compat.h  |    1 -
 src/or/or.h          |    1 -
 src/or/routerparse.c |    2 +-
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/changes/7304 b/changes/7304
new file mode 100644
index 0000000..bfb797b
--- /dev/null
+++ b/changes/7304
@@ -0,0 +1,7 @@
+  o Minor bugfixes:
+    - Replace all calls to snprintf outside of src/ext with tor_snprintf.
+      Fix for bug 7304.
+  o Code simplification and refactoring:
+    - Remove the #define to replace snprintf with _snprintf on windows;
+      they have different semantics, and all of our callers should be
+      using tor_snprintf anyway. Partial fix for bug 7304.
diff --git a/src/common/compat.h b/src/common/compat.h
index 86ea0c4..630682e 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -59,7 +59,6 @@
 #include <io.h>
 #include <math.h>
 #include <projects.h>
-#define snprintf _snprintf
 /* this is not exported as W .... */
 #define SHGetPathFromIDListW SHGetPathFromIDList
 /* wcecompat has vasprintf */
diff --git a/src/or/or.h b/src/or/or.h
index 459e18e..6ec7c3a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -81,7 +81,6 @@
 #include <process.h>
 #include <direct.h>
 #include <windows.h>
-#define snprintf _snprintf
 #endif
 
 #ifdef USE_BUFFEREVENTS
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 1aee4e5..48744d6 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -3828,7 +3828,7 @@ get_next_token(memarea_t *area,
   if ((size_t)(eol-next) != 9+obname_len+5 ||
       strcmp_len(next+9, tok->object_type, obname_len) ||
       strcmp_len(eol-5, "-----", 5)) {
-    snprintf(ebuf, sizeof(ebuf), "Malformed object: mismatched end tag %s",
+    tor_snprintf(ebuf, sizeof(ebuf), "Malformed object: mismatched end tag %s",
              tok->object_type);
     ebuf[sizeof(ebuf)-1] = '\0';
     RET_ERR(ebuf);





More information about the tor-commits mailing list