Commit 21e7fcbb authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

Backport 17891 and 17892 to fix openbsd build warnings. Also backport snarky comments.

svn:r17908
parent 1a19dbef
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@
description of the patch.)

Backport for 0.2.0:
   - r17891: Fix a fun OpenBSD warning.
   - r17892: Fix another fun OpenBSD warning.
   o r17891: Fix a fun OpenBSD warning.
   o r17892: Fix another fun OpenBSD warning.

Backport for 0.2.0 once better tested:
  Xo r16621: Make some DNS code more robust (partial; see also libevent
+10 −1
Original line number Diff line number Diff line
@@ -143,7 +143,16 @@ tor_gzip_compress(char **out, size_t *out_len,
  }
 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);
  }
+5 −0
Original line number Diff line number Diff line
@@ -73,8 +73,13 @@ const char util_c_id[] = "$Id$";
#include <malloc/malloc.h>
#endif
#ifdef HAVE_MALLOC_H
#ifndef OPENBSD
/* OpenBSD has a malloc.h, but for our purposes, it only exists in order to
 * scold us for being so stupid as to autodetect its presence.  To be fair,
 * they've done this since 1996, when autoconf was only 5 years old. */
#include <malloc.h>
#endif
#endif

/* =====
 * Memory management
+2 −0
Original line number Diff line number Diff line
@@ -8,8 +8,10 @@ const char directory_c_id[] =

#include "or.h"
#if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
#ifndef OPENBSD
#include <malloc.h>
#endif
#endif

/**
 * \file directory.c