]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Tweak comments in tor_vasprintf(), and add a changes file for 30651
authorNick Mathewson <nickm@torproject.org>
Wed, 29 May 2019 13:38:32 +0000 (09:38 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 29 May 2019 13:38:57 +0000 (09:38 -0400)
changes/bug30561 [new file with mode: 0644]
src/common/compat.c

diff --git a/changes/bug30561 b/changes/bug30561
new file mode 100644 (file)
index 0000000..afb3f02
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes (portability):
+    - Avoid crashing in our tor_vasprintf() implementation on systems that
+      define neither vasprintf() nor _vscprintf(). (This bug has been here
+      long enough that we question whether people are running Tor on such
+      systems, but we're applying the fix out of caution.) Fixes bug 30561;
+      bugfix on 0.2.8.2-alpha. Found and fixed by Tobias Stoeckmann.
index d3bc2f5fecffaebffb3420b0340d1b769ceb63c1..ee3bf0fd50d8707029a37b076e6def7f5a57a2bd 100644 (file)
@@ -554,13 +554,16 @@ tor_vasprintf(char **strp, const char *fmt, va_list args)
    * characters we need.  We give it a try on a short buffer first, since
    * it might be nice to avoid the second vsnprintf call.
    */
+  /* XXXX This code spent a number of years broken (see bug 30651). It is
+   * possible that no Tor users actually run on systems without vasprintf() or
+   * _vscprintf(). If so, we should consider removing this code. */
   char buf[128];
   int len, r;
   va_list tmp_args;
   va_copy(tmp_args, args);
-  /* Use vsnprintf to retrieve needed length.  tor_vsnprintf() is not an option
-   * here because it will simply return -1 if buf is not large enough to hold the
-   * complete string.
+  /* Use vsnprintf to retrieve needed length.  tor_vsnprintf() is not an
+   * option here because it will simply return -1 if buf is not large enough
+   * to hold the complete string.
    */
   len = vsnprintf(buf, sizeof(buf), fmt, tmp_args);
   va_end(tmp_args);
@@ -3550,4 +3553,3 @@ tor_get_avail_disk_space(const char *path)
   return -1;
 #endif
 }
-