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

svn:r17908
This commit is contained in:
Nick Mathewson 2009-01-05 08:12:33 +00:00
parent 1a19dbef29
commit 21e7fcbbfe
4 changed files with 19 additions and 3 deletions

View File

@ -3,8 +3,8 @@
description of the patch.) description of the patch.)
Backport for 0.2.0: Backport for 0.2.0:
- r17891: Fix a fun OpenBSD warning. o r17891: Fix a fun OpenBSD warning.
- r17892: Fix another fun OpenBSD warning. o r17892: Fix another fun OpenBSD warning.
Backport for 0.2.0 once better tested: Backport for 0.2.0 once better tested:
Xo r16621: Make some DNS code more robust (partial; see also libevent Xo r16621: Make some DNS code more robust (partial; see also libevent

View File

@ -143,7 +143,16 @@ tor_gzip_compress(char **out, size_t *out_len,
} }
done: done:
*out_len = stream->total_out; *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. */ /* If we're wasting more than 4k, don't. */
*out = tor_realloc(*out, stream->total_out + 1); *out = tor_realloc(*out, stream->total_out + 1);
} }

View File

@ -73,8 +73,13 @@ const char util_c_id[] = "$Id$";
#include <malloc/malloc.h> #include <malloc/malloc.h>
#endif #endif
#ifdef HAVE_MALLOC_H #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> #include <malloc.h>
#endif #endif
#endif
/* ===== /* =====
* Memory management * Memory management

View File

@ -8,8 +8,10 @@ const char directory_c_id[] =
#include "or.h" #include "or.h"
#if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO) #if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
#ifndef OPENBSD
#include <malloc.h> #include <malloc.h>
#endif #endif
#endif
/** /**
* \file directory.c * \file directory.c