Fix segmentation fault in mbsdiff and fix crc by linking with libbz2.
authorJason Stephenson <jason@sigio.com>
Tue, 19 Mar 2013 12:38:31 +0000 (08:38 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 29 May 2013 21:38:20 +0000 (17:38 -0400)
Doh! I typed memcpy when I really wanted memset.

This does not actually introduce any new dependencies.  Evergreen
updates/installation already requires bzip2.  If bzip2 is present,
then libbz2 is present.  We don't need libbz2 headers, just the
library itself for a single data structure used in crc32 calculation.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/xul/staff_client/external/libmar/configure.ac
Open-ILS/xul/staff_client/external/libmar/tool/bsdiff.c
Open-ILS/xul/staff_client/external/libmar/tool/crc32.c

index e7715cd..0cfba6e 100644 (file)
@@ -27,6 +27,7 @@ AC_PROG_CC
 AC_PROG_RANLIB
 
 # Checks for libraries.
+AC_CHECK_LIB([bz2],[BZ2_bzCompressInit],,AC_MSG_ERROR(*** OpenILS requires libbz2))
 
 # Checks for header files.
 AC_CHECK_HEADERS([err.h fcntl.h netinet/in.h stdint.h stdio.h stdlib.h string.h sys/stat.h sys/types.h unistd.h])
index ea384bb..9aacd83 100644 (file)
@@ -267,7 +267,7 @@ int main(int argc,char *argv[])
        memcpy(header + 12, &outVal, 4);
        outVal = htonl(newsize);
        memcpy(header + 16, &outVal, 4);
-       memcpy(header + 20, 0, 12);
+       memset(header + 20, 0, 12);
        if (fwrite(header, 32, 1, pf) != 1)
                err(1, "fwrite(%s)", argv[3]);
 
index d249076..3bba38f 100644 (file)
@@ -6,7 +6,7 @@
 #include <stdint.h>
 
 /* This guy lives in libbz2, and is the only reason we need libbz2. */
- extern uint32_t BZ2_crc32Table[256];
+extern uint32_t BZ2_crc32Table[256];
 
 uint32_t
 crc32(const unsigned char *buf, uint32_t len)
@@ -15,7 +15,7 @@ crc32(const unsigned char *buf, uint32_t len)
 
   const unsigned char *end = buf + len;
   for (; buf != end; ++buf)
-    crc = (crc << 8) ^ crc32Table[(crc >> 24) ^ *buf];
+    crc = (crc << 8) ^ BZ2_crc32Table[(crc >> 24) ^ *buf];
 
   crc = ~crc;
   return crc;