[or-cvs] Make detect_compression_method work on platforms with more ...

Nick Mathewson nickm at seul.org
Wed Jan 19 23:07:45 UTC 2005


Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv28943/src/common

Modified Files:
	torgzip.c 
Log Message:
Make detect_compression_method work on platforms with more evil chars.

Index: torgzip.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/torgzip.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- torgzip.c	19 Jan 2005 22:40:32 -0000	1.10
+++ torgzip.c	19 Jan 2005 23:07:43 -0000	1.11
@@ -19,6 +19,7 @@
 #else
 #include <zlib.h>
 #endif
+#include <string.h>
 
 #include "util.h"
 #include "log.h"
@@ -231,10 +232,10 @@
  */
 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;



More information about the tor-commits mailing list