[PATCH] zlib detection for autofoo

Bertrand Jacquin <[email protected]>
Newsgroups gmane.comp.security.virus.clamav.devel
Message-ID <[email protected]>
Hi,

The current configure.ac use many hack to determine if zlib is present,
recent enough. Is a (fast done) patch like this can help you ? The main
idea is to relie on pkg-config.

-- 
Beber

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net
clamav-0.97.7-BJA-zlib-pkg-config.diff (text/plain, 3.1 KB)
--- configure.in.ori	2013-06-09 22:01:31.897359228 +0200
+++ configure.in	2013-06-09 22:26:06.069067617 +0200
@@ -55,6 +55,7 @@
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
+PKG_PROG_PKG_CONFIG
 
 LT_CONFIG_LTDL_DIR([libltdl])
 LT_INIT([dlopen disable-static])
@@ -507,66 +508,22 @@
 have_pthreads=no
 AC_CHECK_HEADER([pthread.h],[have_pthreads=yes],)
 
-AM_MAINTAINER_MODE
-dnl Check for zlib
-AC_MSG_CHECKING([for zlib installation])
-AC_ARG_WITH([zlib],
-[  --with-zlib=DIR	  path to directory containing zlib library (default=
-			  /usr/local or /usr if not found in /usr/local)],
-[
-if test "$withval"; then
-  ZLIB_HOME="$withval"
-  AC_MSG_RESULT([using $ZLIB_HOME])
-fi
-], [
-ZLIB_HOME=/usr/local
-if test ! -f "$ZLIB_HOME/include/zlib.h"
-then
-  ZLIB_HOME=/usr
-fi
-AC_MSG_RESULT([$ZLIB_HOME])
-])
-
 CLAMDSCAN_LIBS="$FRESHCLAM_LIBS"
 
-AC_ARG_ENABLE([zlib-vcheck],
-[  --disable-zlib-vcheck	  do not check for buggy zlib version ],
-zlib_check=$enableval, zlib_check="yes")
-
-if test ! -f "$ZLIB_HOME/include/zlib.h"
-then
-    AC_MSG_ERROR([Please install zlib and zlib-devel packages])
-else
-
-    vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h`
-    if test -z "$vuln"; then
-	vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h`
-    fi
-
-    if test -n "$vuln"; then
-	if test "$zlib_check" = "yes"; then
-	    AC_MSG_ERROR(The installed zlib version may contain a security bug. Please upgrade to 1.2.2 or later: http://www.zlib.net. You can omit this check with --disable-zlib-vcheck but DO NOT REPORT any stability issues then!)
-	else
-	    AC_MSG_WARN([****** This ClamAV installation may be linked against])
-	    AC_MSG_WARN([****** a broken zlib version. Please DO NOT report any])
-	    AC_MSG_WARN([****** stability problems to the ClamAV developers!])
-	fi
-    fi
-
-    save_LIBS="$LIBS"
-    if test "$ZLIB_HOME" != "/usr"; then
-	CPPFLAGS="$CPPFLAGS -I$ZLIB_HOME/include"
-	save_LDFLAGS="$LDFLAGS"
-	LDFLAGS="$LDFLAGS -L$ZLIB_HOME/lib"
-	AC_CHECK_LIB([z], [inflateEnd], [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -L$ZLIB_HOME/lib -lz"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -L$ZLIB_HOME/lib -lz"], AC_MSG_ERROR([Please install zlib and zlib-devel packages]))
-	AC_CHECK_LIB([z], [gzopen], [], AC_MSG_ERROR([Your zlib is missing gzopen()]))
-	LDFLAGS="$save_LDFLAGS"
-    else
-	AC_CHECK_LIB([z], [inflateEnd], [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lz";FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lz"], AC_MSG_ERROR([Please install zlib and zlib-devel packages]))
-	AC_CHECK_LIB([z], [gzopen],[], AC_MSG_ERROR([Your zlib is missing gzopen()]))
-    fi
-    LIBS="$save_LIBS"
-fi
+AM_MAINTAINER_MODE
+dnl Check for zlib
+PKG_CHECK_MODULES([zlib], [zlib > 1.2.1],
+    [CPPFLAGS="$CPPFLAGS $zlib_CFLAGS"
+     LDFLAGS="$LDFLAGS $zlib_LIBS"
+
+     AC_CHECK_LIB([z], [inflateEnd],
+         [LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $zlib_LIBS"
+	  FRESHCLAM_LIBS="$FRESHCLAM_LIBS $zlib_LIBS"],
+	 [AC_MSG_ERROR([Please install zlib and zlib-devel packages])])
+     AC_CHECK_LIB([z], [gzopen],
+         [],
+	 [AC_MSG_ERROR([Your zlib is missing gzopen()])])
+    ])
 
 AC_ARG_ENABLE([bzip2],
 [  --disable-bzip2	  disable bzip2 support],
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.