[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17892: {tor} Another fun openbsd warning fix. On ioerror's computer at le (tor/trunk/src/common)



Author: nickm
Date: 2009-01-04 18:15:42 -0500 (Sun, 04 Jan 2009)
New Revision: 17892

Modified:
   tor/trunk/src/common/torgzip.c
Log:
Another fun openbsd warning fix.  On ioerror's computer at least, they redefined an unsigned field in zlib.h to be signed.  I am quite sure this makes me more secure somehow.

Modified: tor/trunk/src/common/torgzip.c
===================================================================
--- tor/trunk/src/common/torgzip.c	2009-01-04 22:47:42 UTC (rev 17891)
+++ tor/trunk/src/common/torgzip.c	2009-01-04 23:15:42 UTC (rev 17892)
@@ -140,7 +140,16 @@
   }
  done:
   *out_len = stream->total_out;
-  if (stream->total_out > out_size + 4097) {
+#ifdef OPENBSD
+  /* "Hey Rocky!  Watch me change an unsigned field to a signed field in a
+   *    third-party API!"
+   * "Oh, that trick will just make people do unsafe casts to the unsigned
+   *    type in their cross-platform code!"
+   * "Don't be foolish.  I'm _sure_ they'll have the good sense to make sure
+   *    the newly unsigned field isn't negative." */
+  tor_assert(stream->total_out >= 0);
+#endif
+  if (((size_t)stream->total_out) > out_size + 4097) {
     /* If we're wasting more than 4k, don't. */
     *out = tor_realloc(*out, stream->total_out + 1);
   }