From fae26cc3f747816c936a0018b5fc13ed25c9a024 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Mon, 6 Aug 2012 21:22:33 -0500
Subject: gdbm 1.10

---
 abs/core/gdbm/PKGBUILD                    |  65 +++++++++-----
 abs/core/gdbm/__changelog                 |   2 -
 abs/core/gdbm/gdbm-1.10-zeroheaders.patch |  33 +++++++
 abs/core/gdbm/gdbm-1.8.3-fhs.patch        | 138 ------------------------------
 4 files changed, 75 insertions(+), 163 deletions(-)
 delete mode 100644 abs/core/gdbm/__changelog
 create mode 100644 abs/core/gdbm/gdbm-1.10-zeroheaders.patch
 delete mode 100644 abs/core/gdbm/gdbm-1.8.3-fhs.patch

diff --git a/abs/core/gdbm/PKGBUILD b/abs/core/gdbm/PKGBUILD
index 91744e4..30570dd 100644
--- a/abs/core/gdbm/PKGBUILD
+++ b/abs/core/gdbm/PKGBUILD
@@ -1,38 +1,57 @@
-# $Id: PKGBUILD 73046 2010-03-22 00:42:44Z allan $
-# Maintainer: Allan McRae <allan@archlinux.org>
+# $Id: PKGBUILD 143800 2011-11-29 13:32:53Z stephane $
+# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
+# Contributor: Allan McRae <allan@archlinux.org>
 # Contributor: judd <jvinet@zeroflux.org>
 
 pkgname=gdbm
-pkgver=1.8.3
-pkgrel=15
+pkgver=1.10
+pkgrel=1
 pkgdesc="GNU database library"
 url="http://www.gnu.org/software/gdbm/gdbm.html"
 license=('GPL')
 arch=('i686' 'x86_64')
 depends=('glibc' 'sh')
-source=(ftp://ftp.gnu.org/gnu/gdbm/$pkgname-$pkgver.tar.gz
-	gdbm-1.8.3-fhs.patch)
+source=(ftp://ftp.gnu.org/gnu/gdbm/${pkgname}-${pkgver}.tar.gz
+        gdbm-1.10-zeroheaders.patch)
 options=('!libtool' '!makeflags')
 install=gdbm.install
-
+md5sums=('88770493c2559dc80b561293e39d3570'
+         'ac255b10452005237836cd2d3a470733')
 build() {
-  cd $srcdir/$pkgname-$pkgver
-  patch -Np1 -i $srcdir/gdbm-1.8.3-fhs.patch
+  cd "${srcdir}/${pkgname}-${pkgver}"
 
-  libtoolize --force --copy
-  aclocal
-  autoconf 
-  
-  ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
-  make prefix=/usr || return 1
+  # Prevent gdbm from storing uninitialized memory content
+  # to database files. This patch improves security, as the
+  # uninitialized memory might contain sensitive informations
+  # from other applications.
+  # https://bugzilla.redhat.com/show_bug.cgi?id=4457
+  # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208927
+  patch -Np1 -i ../gdbm-1.10-zeroheaders.patch
 
-  make prefix=$pkgdir/usr \
-       manprefix=$pkgdir/usr/share/man \
-       man3dir=$pkgdir/usr/share/man/man3 \
-       infodir=$pkgdir/usr/share/info \
-       install install-compat
+  ./configure --prefix=/usr \
+              --mandir=/usr/share/man \
+              --infodir=/usr/share/info \
+              --enable-libgdbm-compat
+
+  make prefix=/usr
+}
 
-  ln -sf gdbm/gdbm.h $pkgdir/usr/include
+check() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+  make check
+}
+
+package() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+  make prefix="${pkgdir}"/usr \
+       manprefix="${pkgdir}"/usr/share/man \
+       man3dir="${pkgdir}"/usr/share/man/man3 \
+       infodir="${pkgdir}"/usr/share/info \
+       install
+  
+  # create symlinks for compatibility
+  install -dm755 "${pkgdir}"/usr/include/gdbm
+  ln -sf ../gdbm.h "${pkgdir}"/usr/include/gdbm/gdbm.h
+  ln -sf ../ndbm.h "${pkgdir}"/usr/include/gdbm/ndbm.h
+  ln -sf ../dbm.h  "${pkgdir}"/usr/include/gdbm/dbm.h
 }
-md5sums=('1d1b1d5c0245b1c00aff92da751e9aa1'
-         'a5bb00f10f4d8317435c4cf471b6ced4')
diff --git a/abs/core/gdbm/__changelog b/abs/core/gdbm/__changelog
deleted file mode 100644
index 7eaaf1d..0000000
--- a/abs/core/gdbm/__changelog
+++ /dev/null
@@ -1,2 +0,0 @@
-Add -lgdbm_compat to line 104 of gdbm-1.8.3-fhs.patch. Python2.6 would not
-  build "dbm" module without this.
diff --git a/abs/core/gdbm/gdbm-1.10-zeroheaders.patch b/abs/core/gdbm/gdbm-1.10-zeroheaders.patch
new file mode 100644
index 0000000..a268f6b
--- /dev/null
+++ b/abs/core/gdbm/gdbm-1.10-zeroheaders.patch
@@ -0,0 +1,33 @@
+diff -up gdbm-1.10/src/falloc.c.zeroheaders gdbm-1.10/src/falloc.c
+--- gdbm-1.10/src/falloc.c.zeroheaders	2011-11-11 11:59:11.000000000 +0100
++++ gdbm-1.10/src/falloc.c	2011-11-14 17:34:32.487604027 +0100
+@@ -255,7 +255,7 @@ push_avail_block (GDBM_FILE dbf)
+ 
+ 
+   /* Split the header block. */
+-  temp = (avail_block *) malloc (av_size);
++  temp = (avail_block *) calloc (1, av_size);
+   if (temp == NULL) _gdbm_fatal (dbf, _("malloc error"));
+   /* Set the size to be correct AFTER the pop_avail_block. */
+   temp->size = dbf->header->avail.size;
+diff -up gdbm-1.10/src/gdbmopen.c.zeroheaders gdbm-1.10/src/gdbmopen.c
+--- gdbm-1.10/src/gdbmopen.c.zeroheaders	2011-11-11 19:39:42.000000000 +0100
++++ gdbm-1.10/src/gdbmopen.c	2011-11-14 17:33:24.867608650 +0100
+@@ -264,7 +264,7 @@ gdbm_open (const char *file, int block_s
+ 	(dbf->header->block_size - sizeof (hash_bucket))
+ 	/ sizeof (bucket_element) + 1;
+       dbf->header->bucket_size  = dbf->header->block_size;
+-      dbf->bucket = (hash_bucket *) malloc (dbf->header->bucket_size);
++      dbf->bucket = (hash_bucket *) calloc (1, dbf->header->bucket_size);
+       if (dbf->bucket == NULL)
+ 	{
+ 	  gdbm_close (dbf);
+@@ -456,7 +456,7 @@ _gdbm_init_cache(GDBM_FILE dbf, size_t s
+       for(index = 0; index < size; index++)
+         {
+           (dbf->bucket_cache[index]).ca_bucket
+-            = (hash_bucket *) malloc (dbf->header->bucket_size);
++            = (hash_bucket *) calloc (1, dbf->header->bucket_size);
+           if ((dbf->bucket_cache[index]).ca_bucket == NULL)
+ 	    {
+               gdbm_errno = GDBM_MALLOC_ERROR;
diff --git a/abs/core/gdbm/gdbm-1.8.3-fhs.patch b/abs/core/gdbm/gdbm-1.8.3-fhs.patch
deleted file mode 100644
index 5b405d9..0000000
--- a/abs/core/gdbm/gdbm-1.8.3-fhs.patch
+++ /dev/null
@@ -1,138 +0,0 @@
-diff -up gdbm-1.8.3/Makefile.in.fhs gdbm-1.8.3/Makefile.in
---- gdbm-1.8.3/Makefile.in.fhs	2002-10-08 18:09:12.000000000 +0200
-+++ gdbm-1.8.3/Makefile.in	2010-03-10 15:41:01.516025096 +0100
-@@ -1,7 +1,7 @@
- #### Start of system configuration section. ####
- 
- srcdir = @srcdir@
--top_builddir = .
-+top_builddir = @top_builddir@
- VPATH = @srcdir@
- 
- CC = @CC@
-@@ -14,17 +14,13 @@ INSTALL = @INSTALL@
- INSTALL_PROGRAM = @INSTALL_PROGRAM@
- INSTALL_DATA = @INSTALL_DATA@
- 
--# File ownership and group
--BINOWN = bin
--BINGRP = bin
--
- MAKEINFO = makeinfo
- TEXI2DVI = texi2dvi
- 
--DEFS =
-+DEFS = @DEFS@
- 
- # Where the system [n]dbm routines are...
--LIBS = @LIBS@ -lc
-+LIBS = @LIBS@
- 
- CFLAGS = @CFLAGS@
- LDFLAGS = @LDFLAGS@
-@@ -32,16 +28,17 @@ LDFLAGS = @LDFLAGS@
- # Common prefix for installation directories
- prefix = @prefix@
- exec_prefix = @exec_prefix@
--binprefix = $(exec_prefix)
--manprefix = $(prefix)
-+datarootdir = @datarootdir@
- 
- # Directory in which to put libgdbm.a.
- libdir = @libdir@
- # The include directory for gdbm.h and dbm.h.
- includedir = @includedir@
-+pkgincludedir = $(includedir)/gdbm
- # Info and man directories.
- infodir = @infodir@
--man3dir = @mandir@/man3
-+mandir = @mandir@
-+man3dir = $(mandir)/man3
- manext = 3
- 
- #### End of system configuration section. ####
-@@ -57,7 +54,7 @@ manext = 3
- 
- SHELL = /bin/sh
- 
--PROGS = libgdbm.la testgdbm testdbm testndbm tndbm tdbm conv2gdbm
-+PROGS = libgdbm.la testgdbm testdbm testndbm conv2gdbm
- 
- DBM_CF = dbminit.c delete.c fetch.c store.c seq.c close.c
- 
-@@ -127,26 +124,17 @@ all: libgdbm.la libgdbm_compat.la
- progs: $(PROGS)
- 
- install: libgdbm.la gdbm.h gdbm.info
--	$(srcdir)/mkinstalldirs $(INSTALL_ROOT)$(libdir) \
--		$(INSTALL_ROOT)$(includedir) $(INSTALL_ROOT)$(man3dir) \
--		$(INSTALL_ROOT)$(infodir)
--	$(LIBTOOL) $(INSTALL) -c libgdbm.la $(INSTALL_ROOT)$(libdir)/libgdbm.la
--	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) gdbm.h \
--		$(INSTALL_ROOT)$(includedir)/gdbm.h
--	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/gdbm.3 \
--		$(INSTALL_ROOT)$(man3dir)/gdbm.3
--	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/gdbm.info \
--		$(INSTALL_ROOT)$(infodir)/gdbm.info
-+	$(srcdir)/mkinstalldirs $(libdir) $(pkgincludedir) $(man3dir) $(infodir)
-+	$(LIBTOOL) install install libgdbm.la $(libdir)/libgdbm.la
-+	$(INSTALL_DATA) gdbm.h $(pkgincludedir)/gdbm.h
-+	$(INSTALL_DATA) $(srcdir)/gdbm.3 $(man3dir)/gdbm.3
-+	$(INSTALL_DATA) $(srcdir)/gdbm.info $(infodir)/gdbm.info
- 
- install-compat:
--	$(srcdir)/mkinstalldirs $(INSTALL_ROOT)$(libdir) \
--		$(INSTALL_ROOT)$(includedir)
--	$(LIBTOOL) $(INSTALL) -c libgdbm_compat.la \
--		$(INSTALL_ROOT)$(libdir)/libgdbm_compat.la
--	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/dbm.h \
--		$(INSTALL_ROOT)$(includedir)/dbm.h
--	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/ndbm.h \
--		$(INSTALL_ROOT)$(includedir)/ndbm.h
-+	$(srcdir)/mkinstalldirs $(libdir) $(pkgincludedir)
-+	$(LIBTOOL) install install libgdbm_compat.la $(libdir)/libgdbm_compat.la
-+	$(INSTALL_DATA) $(srcdir)/dbm.h $(pkgincludedir)/dbm.h
-+	$(INSTALL_DATA) $(srcdir)/ndbm.h $(pkgincludedir)/ndbm.h
- 
- #libgdbm.a: $(OBJS) gdbm.h
- #	rm -f libgdbm.a
-@@ -161,7 +149,7 @@ libgdbm.la: $(LOBJS) gdbm.h
- libgdbm_compat.la: $(C_LOBJS) gdbm.h
- 	rm -f libgdbm_compat.la
- 	$(LIBTOOL) --mode=link $(CC) -o libgdbm_compat.la -rpath $(libdir) \
--		-version-info $(SHLIB_VER) $(C_LOBJS)
-+		-version-info $(SHLIB_VER) $(C_LOBJS) -lgdbm_compat -lgdbm
- 
- gdbm.h:	gdbm.proto gdbmerrno.h gdbm.proto2
- 	rm -f gdbm.h
-@@ -172,10 +160,10 @@ gdbm.h:	gdbm.proto gdbmerrno.h gdbm.prot
- 	chmod -w gdbm.h
- 
- testgdbm: testgdbm.o libgdbm.la @LIBOBJS@
--	$(LIBTOOL) $(CC) $(LDFLAGS) -o testgdbm testgdbm.o libgdbm.la @LIBOBJS@
-+	$(LIBTOOL) link $(CC) $(LDFLAGS) -o testgdbm testgdbm.o libgdbm.la @LIBOBJS@
- 
- testdbm: testdbm.o libgdbm.la libgdbm_compat.la
--	$(LIBTOOL) $(CC) $(LDFLAGS) -o testdbm testdbm.o libgdbm.la libgdbm_compat.la
-+	$(LIBTOOL) link $(CC) $(LDFLAGS) -o testdbm testdbm.o $(LIBS) libgdbm_compat.la
- 
- tdbm: testdbm.o
- 	$(CC) $(LDFLAGS) -o tdbm testdbm.o $(LIBS)
-@@ -184,7 +172,7 @@ testndbm.o: testndbm.c
- 	$(CC) -c -I. -I$(srcdir) $(CFLAGS) $(DEFS) -DGNU $(srcdir)/testndbm.c
- 
- testndbm: testndbm.o libgdbm.la libgdbm_compat.la
--	$(LIBTOOL) $(CC) $(LDFLAGS) -o testndbm testndbm.o libgdbm.la libgdbm_compat.la
-+	$(LIBTOOL) link $(CC) $(LDFLAGS) -o testndbm testndbm.o libgdbm_compat.la
- 
- tndbm.o: testndbm.c
- 	cp $(srcdir)/testndbm.c ./tndbm.c
-@@ -195,7 +183,7 @@ tndbm: tndbm.o
- 	$(CC) $(LDFLAGS) -o tndbm tndbm.o $(LIBS)
- 
- conv2gdbm: conv2gdbm.o libgdbm.la @LIBOBJS@
--	$(LIBTOOL) $(CC) $(LDFLAGS) -o conv2gdbm conv2gdbm.o $(LIBS) libgdbm.la @LIBOBJS@
-+	$(LIBTOOL) link $(CC) $(LDFLAGS) -o conv2gdbm conv2gdbm.o $(LIBS) libgdbm_compat.la @LIBOBJS@
- 
- lintgdbm: 
- 	lint $(DEFS) $(LFLAGS) $(DBM_CF) $(NDBM_CF) $(GDBM_CF) testgdbm.c
-- 
cgit v0.12

