Check length of string read from zip file before
comparing with original string, since we do not NUL-terminate it in the ZIP file.

--HG--
branch : HEAD
diff --git a/ChangeLog b/ChangeLog
index ab402ec..362d9d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
 2005-06-09  Thomas Klausner  <wiz@danbala.tuwien.ac.at>
 
+	* regress/buffadd.c (main): check string length before comparing.
 	* ltmain.sh: update from libtool-1.5.18.
 	* compile, depcomp, install-sh, missing, mkinstalldirs: Update
 	from automake-1.9.5.
diff --git a/regress/buffadd.c b/regress/buffadd.c
index fead70e..2fe257a 100644
--- a/regress/buffadd.c
+++ b/regress/buffadd.c
@@ -1,5 +1,5 @@
 /*
-  $NiH: buffadd.c,v 1.9 2005/01/11 17:45:00 wiz Exp $
+  $NiH: buffadd.c,v 1.10 2005/06/09 20:04:45 dillo Exp $
 
   buffadd.c -- test cases for adding files from buffer
   Copyright (C) 1999, 2003, 2005 Dieter Baron and Thomas Klausner
@@ -53,6 +53,7 @@
     struct zip_file *zf;
     struct zip_source *zs;
     int err;
+    int len;
     
     char buf[2000];
 
@@ -92,7 +93,7 @@
 	exit(1);
     }
 
-    if (zip_fread(zf, buf, 2000) < 0) {
+    if ((len=zip_fread(zf, buf, 2000)) < 0) {
 	fprintf(stderr,"%s: can't read from '%s' in zip archive '%s': %s\n",
 		argv[0], testname, testzip, zip_file_strerror(zf));
 	exit(1);
@@ -101,7 +102,8 @@
     zip_fclose(zf);
     zf = zip_fopen(za, testname, 0);
 
-    if (strcmp(buf, teststr)) {
+    /* not NUL-terminated, so we have to check length manually */
+    if (len != strlen(teststr) || strncmp(buf, teststr, len)) {
 	fprintf(stderr,"%s: wrong data: '%s' instead of '%s'\n", argv[0],
 		buf, teststr);
 	exit(1);