diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-01-19 23:07:43 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-01-19 23:07:43 +0000 |
commit | 2c803bff9a62d4fbedd953b442d79e6f82d0ea0b (patch) | |
tree | aa93b03199ada48346610fbda8e29838be5f98e0 /src/common/torgzip.c | |
parent | 1eddb28f82c7b8a23b9552e8bbd460a485d0341e (diff) | |
download | tor-2c803bff9a62d4fbedd953b442d79e6f82d0ea0b.tar tor-2c803bff9a62d4fbedd953b442d79e6f82d0ea0b.tar.gz |
Make detect_compression_method work on platforms with more evil chars.
svn:r3376
Diffstat (limited to 'src/common/torgzip.c')
-rw-r--r-- | src/common/torgzip.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/torgzip.c b/src/common/torgzip.c index 1705e6bc9..4bb39f2be 100644 --- a/src/common/torgzip.c +++ b/src/common/torgzip.c @@ -19,6 +19,7 @@ const char torgzip_c_id[] = "$Id$"; #else #include <zlib.h> #endif +#include <string.h> #include "util.h" #include "log.h" @@ -231,10 +232,10 @@ tor_gzip_uncompress(char **out, size_t *out_len, */ int detect_compression_method(const char *in, size_t in_len) { - if (in_len > 2 && in[0] == 0x1f && in[1] == 0x8b) { + if (in_len > 2 && !memcmp(in, "\x1f\x8b", 2)) { return GZIP_METHOD; } else if (in_len > 2 && (in[0] & 0x0f) == 8 && - get_uint16(in) % 31 == 0) { + (get_uint16(in) % 31) == 0) { return ZLIB_METHOD; } else { return 0; |