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

[or-cvs] Allow tor_gzip_uncompress to handle multiple concatenated c...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv8218/src/or

Modified Files:
	test.c 
Log Message:
Allow tor_gzip_uncompress to handle multiple concatenated compressed strings.

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -d -r1.196 -r1.197
--- test.c	26 Aug 2005 23:22:27 -0000	1.196
+++ test.c	29 Aug 2005 18:01:38 -0000	1.197
@@ -908,7 +908,7 @@
   char *buf1, *buf2=NULL, *buf3=NULL;
   size_t len1, len2;
 
-  buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
+  buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ");
   test_eq(detect_compression_method(buf1, strlen(buf1)), 0);
   if (is_gzip_supported()) {
     test_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
@@ -935,6 +935,16 @@
   test_assert(buf3);
   test_streq(buf1,buf3);
 
+  tor_free(buf3);
+  buf2 = tor_realloc(buf2, len1*2);
+  memcpy(buf2+len1, buf2, len1);
+  test_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1*2, ZLIB_METHOD));
+  test_eq(len2, (strlen(buf1)+1)*2);
+  test_memeq(buf3,
+             "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0"
+             "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0",
+             (strlen(buf1)+1)*2);
+
   tor_free(buf2);
   tor_free(buf3);
   tor_free(buf1);