Rebase onto 1.18.1

This commit is contained in:
Filip Januš 2019-10-02 16:24:27 +02:00
parent 08c18d2386
commit eb40671f4a
6 changed files with 10 additions and 348 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/gdbm-1.16.tar.gz /gdbm-1.16.tar.gz
/gdbm-1.17.tar.gz /gdbm-1.17.tar.gz
/gdbm-1.18.tar.gz /gdbm-1.18.tar.gz
/gdbm-1.18.1.tar.gz

View File

@ -1,14 +0,0 @@
diff -up gdbm-1.10/NOTE-WARNING.fedora gdbm-1.10/NOTE-WARNING
--- gdbm-1.10/NOTE-WARNING.fedora 2011-11-14 17:43:41.267566501 +0100
+++ gdbm-1.10/NOTE-WARNING 2011-11-14 17:47:53.312549265 +0100
@@ -12,8 +12,8 @@ systems where it is not the default. `L
when a system uses 64bit file offsets. Gdbm has, of course, supported `large
files' on systems where it was the default for a very long time.
-On some systems, such as Solaris, this functionality is not enabled by
-default. Gdbm will now enable it. THIS MEANS THAT GDBM 1.9 MAY NOT BE
+On some systems this functionality is not enabled by default. To enable it,
+build rpm with option --with=largefile. THIS MEANS THAT GDBM 1.9 MAY NOT BE
ABLE TO ACCESS DATABASES CREATED BY PREVIOUS VERIONS ON THE SAME SYSTEM.
Running the `configure' script with the `--disable-largefile' flag should

View File

@ -1,298 +0,0 @@
From 2ff4ae9c745d4b9e6ee36468c81554027f66c35b Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Fri, 31 Aug 2018 08:26:31 +0000
Subject: Various bugfixes.
* compat/dbmopen.c (ndbm_open_dir_file0): Ignore ENOENT.
* src/falloc.c (push_avail_block): Free temporary storage no matter
what return status.
* src/gdbm.h.in (GDBM_FILE_TRUNCATE_ERROR): New error code.
* src/gdbmdump.c (_gdbm_dump_ascii): Initialize rc.
* src/gdbmerrno.c: Handle new error.code
* src/gdbmload.c (gdbm_load_bdb_dump): Initialize rc
* src/gdbmopen.c (_gdbm_ftruncate): New function.
(gdbm_fd_open): Use _gdbm_ftruncate. Check its return.
* src/gdbmseq.c (gdbm_firstkey): Initialize dsize
* src/gdbmtool.c (command_generator): Check if cmd is NULL.
(shouldn't happen, but anyways).
* src/mmap.c (_gdbm_mapped_lseek): Check for vailidity of the 'whence'
parameter.
* src/systems.h (TRUNCATE): Remove macro.
* src/util.c (vgetyn): Remove unnecessary assignment.
---
diff --git a/compat/dbmopen.c b/compat/dbmopen.c
index b9e7518..0538992 100644
--- a/compat/dbmopen.c
+++ b/compat/dbmopen.c
@@ -87,7 +87,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
if ((mode & GDBM_OPENMASK) == GDBM_READER)
/* Ok, try to cope with it. */
return pagfd;
- else
+ else if (errno != ENOENT)
{
gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
return -1;
diff --git a/src/falloc.c b/src/falloc.c
index 09b40d4..7a94afb 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -313,33 +313,43 @@ push_avail_block (GDBM_FILE dbf)
/* Update the header avail count to previous size divided by 2. */
dbf->header->avail.count >>= 1;
- /* Free the unneeded space. */
- new_loc.av_adr += av_size;
- new_loc.av_size -= av_size;
- _gdbm_free (dbf, new_loc.av_adr, new_loc.av_size);
-
- /* Update the disk. */
- file_pos = gdbm_file_seek (dbf, av_adr, SEEK_SET);
- if (file_pos != av_adr)
+ rc = 0;
+ do
{
- GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
- _gdbm_fatal (dbf, _("lseek error"));
- return -1;
- }
+ /* Free the unneeded space. */
+ new_loc.av_adr += av_size;
+ new_loc.av_size -= av_size;
+ if (_gdbm_free (dbf, new_loc.av_adr, new_loc.av_size))
+ {
+ rc = -1;
+ break;
+ }
+
+ /* Update the disk. */
+ file_pos = gdbm_file_seek (dbf, av_adr, SEEK_SET);
+ if (file_pos != av_adr)
+ {
+ GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
+ _gdbm_fatal (dbf, _("lseek error"));
+ rc = -1;
+ break;
+ }
- rc = _gdbm_full_write (dbf, temp, av_size);
- if (rc)
- {
- GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
- "%s: error writing avail data: %s",
- dbf->name, gdbm_db_strerror (dbf));
- _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
- return -1;
+ rc = _gdbm_full_write (dbf, temp, av_size);
+ if (rc)
+ {
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: error writing avail data: %s",
+ dbf->name, gdbm_db_strerror (dbf));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
+ rc = -1;
+ }
}
-
+ while (0);
+
free (temp);
- return 0;
+ return rc;
}
/* AV_TABLE contains COUNT entries sorted by AV_SIZE in ascending order.
diff --git a/src/gdbm.h.in b/src/gdbm.h.in
index 6318ad8..f5eadc5 100644
--- a/src/gdbm.h.in
+++ b/src/gdbm.h.in
@@ -227,9 +227,10 @@ extern int gdbm_copy_meta (GDBM_FILE dst, GDBM_FILE src);
# define GDBM_BAD_DIR_ENTRY 36
# define GDBM_FILE_CLOSE_ERROR 37
# define GDBM_FILE_SYNC_ERROR 38
+# define GDBM_FILE_TRUNCATE_ERROR 39
# define _GDBM_MIN_ERRNO 0
-# define _GDBM_MAX_ERRNO GDBM_FILE_SYNC_ERROR
+# define _GDBM_MAX_ERRNO GDBM_FILE_TRUNCATE_ERROR
/* This one was never used and will be removed in the future */
# define GDBM_UNKNOWN_UPDATE GDBM_UNKNOWN_ERROR
diff --git a/src/gdbmdump.c b/src/gdbmdump.c
index 2e6f5b0..a8c4ec5 100644
--- a/src/gdbmdump.c
+++ b/src/gdbmdump.c
@@ -62,7 +62,7 @@ _gdbm_dump_ascii (GDBM_FILE dbf, FILE *fp)
size_t count = 0;
unsigned char *buffer = NULL;
size_t bufsize = 0;
- int rc;
+ int rc = 0;
fd = gdbm_fdesc (dbf);
if (fstat (fd, &st))
diff --git a/src/gdbmerrno.c b/src/gdbmerrno.c
index 4ce7f9d..6758272 100644
--- a/src/gdbmerrno.c
+++ b/src/gdbmerrno.c
@@ -138,7 +138,8 @@ const char * const gdbm_errlist[_GDBM_MAX_ERRNO+1] = {
[GDBM_BAD_HASH_TABLE] = N_("Malformed hash table"),
[GDBM_BAD_DIR_ENTRY] = N_("Invalid directory entry"),
[GDBM_FILE_CLOSE_ERROR] = N_("Error closing file"),
- [GDBM_FILE_SYNC_ERROR] = N_("Error synchronizing file")
+ [GDBM_FILE_SYNC_ERROR] = N_("Error synchronizing file"),
+ [GDBM_FILE_TRUNCATE_ERROR] = N_("Error truncating file")
};
const char *
@@ -182,7 +183,8 @@ int const gdbm_syserr[_GDBM_MAX_ERRNO+1] = {
[GDBM_FILE_STAT_ERROR] = 1,
[GDBM_BACKUP_FAILED] = 1,
[GDBM_FILE_CLOSE_ERROR] = 1,
- [GDBM_FILE_SYNC_ERROR] = 1
+ [GDBM_FILE_SYNC_ERROR] = 1,
+ [GDBM_FILE_TRUNCATE_ERROR] = 1
};
/* Returns true if system errno value is meaningful for GDBM error
diff --git a/src/gdbmload.c b/src/gdbmload.c
index 008bcb9..f5b7869 100644
--- a/src/gdbmload.c
+++ b/src/gdbmload.c
@@ -542,6 +542,7 @@ gdbm_load_bdb_dump (struct dump_file *file, GDBM_FILE dbf, int replace)
memset (&xd, 0, sizeof (xd));
xs[0] = xs[1] = 0;
i = 0;
+ rc = 0;
while ((c = fgetc (file->fp)) == ' ')
{
rc = xdatum_read (file->fp, &xd[i], &xs[i]);
diff --git a/src/gdbmopen.c b/src/gdbmopen.c
index 908887c..7ec57e7 100644
--- a/src/gdbmopen.c
+++ b/src/gdbmopen.c
@@ -199,6 +199,21 @@ validate_header (gdbm_file_header const *hdr, struct stat const *st)
return 0;
}
+/* Do we have ftruncate? */
+static inline int
+_gdbm_ftruncate (GDBM_FILE dbf)
+{
+#if HAVE_FTRUNCATE
+ return ftruncate (dbf->desc, 0);
+#else
+ int fd;
+ fd = open (dbf->name, O_RDWR|O_TRUNC, mode);
+ if (fd == -1)
+ return -1;
+ return close (fd);
+#endif
+}
+
GDBM_FILE
gdbm_fd_open (int fd, const char *file_name, int block_size,
int flags, void (*fatal_func) (const char *))
@@ -320,14 +335,22 @@ gdbm_fd_open (int fd, const char *file_name, int block_size,
now time to truncate the file. */
if ((flags & GDBM_OPENMASK) == GDBM_NEWDB && file_stat.st_size != 0)
{
- TRUNCATE (dbf);
- if (fstat (dbf->desc, &file_stat))
+ if (_gdbm_ftruncate (dbf))
+ {
+ GDBM_SET_ERRNO2 (dbf, GDBM_FILE_TRUNCATE_ERROR, FALSE,
+ GDBM_DEBUG_OPEN);
+ }
+ else if (fstat (dbf->desc, &file_stat))
+ {
+ GDBM_SET_ERRNO2 (dbf, GDBM_FILE_STAT_ERROR, FALSE, GDBM_DEBUG_OPEN);
+ }
+
+ if (gdbm_last_errno (dbf))
{
if (flags & GDBM_CLOERROR)
close (dbf->desc);
free (dbf->name);
free (dbf);
- GDBM_SET_ERRNO2 (NULL, GDBM_FILE_STAT_ERROR, FALSE, GDBM_DEBUG_OPEN);
return NULL;
}
}
diff --git a/src/gdbmseq.c b/src/gdbmseq.c
index e74d78d..ee7ebf3 100644
--- a/src/gdbmseq.c
+++ b/src/gdbmseq.c
@@ -101,6 +101,7 @@ gdbm_firstkey (GDBM_FILE dbf)
/* Set the default return value for not finding a first entry. */
return_val.dptr = NULL;
+ return_val.dsize = 0;
GDBM_DEBUG (GDBM_DEBUG_READ, "%s: getting first key", dbf->name);
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 454465e..8c97e1e 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -1435,7 +1435,7 @@ command_generator (const char *text, int state)
len = strlen (text);
}
- if (!cmd->name)
+ if (!cmd || !cmd->name)
return NULL;
/* Return the next name which partially matches from the command list. */
diff --git a/src/mmap.c b/src/mmap.c
index 48e84ae..148b852 100644
--- a/src/mmap.c
+++ b/src/mmap.c
@@ -367,6 +367,10 @@ _gdbm_mapped_lseek (GDBM_FILE dbf, off_t offset, int whence)
needle = file_size - offset;
break;
}
+
+ default:
+ errno = EINVAL;
+ return -1;
}
if (needle < 0)
diff --git a/src/systems.h b/src/systems.h
index 750aa51..f269060 100644
--- a/src/systems.h
+++ b/src/systems.h
@@ -52,13 +52,6 @@
# define STATBLKSIZE(st) 1024
#endif
-/* Do we have ftruncate? */
-#if HAVE_FTRUNCATE
-# define TRUNCATE(dbf) ftruncate (dbf->desc, 0)
-#else
-# define TRUNCATE(dbf) close( open (dbf->name, O_RDWR|O_TRUNC, mode));
-#endif
-
#ifndef STDERR_FILENO
# define STDERR_FILENO 2
#endif
diff --git a/src/util.c b/src/util.c
index f254202..3493366 100644
--- a/src/util.c
+++ b/src/util.c
@@ -98,8 +98,9 @@ vgetyn (const char *prompt, va_list ap)
default:
fprintf (stdout, "%s\n", _("Please, reply 'y' or 'n'"));
}
- state = 0;
- } else
+ /* fall through */
+ }
+ else
break;
case 0:
--
cgit v0.9.0.3

View File

@ -1,27 +0,0 @@
From 64ef7e827406f91d31bffdcad9f4b8aaad1f874c Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Sun, 19 Aug 2018 06:50:22 +0000
Subject: Fix directory entry validation.
Bug reported by Miroslav Lichvar and Marek Skalický
* src/bucket.c (gdbm_dir_entry_valid_p): Fix lower limit for
the allowed bucket address. Initial allocation of second block
for the directory can be eventually returned to the available
list when the directory is expanded during bucket splitting.
---
diff --git a/src/bucket.c b/src/bucket.c
index 0597965..3d267e2 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -54,7 +54,7 @@ gdbm_dir_entry_valid_p (GDBM_FILE dbf, int dir_index)
{
return dir_index >= 0
&& dir_index < GDBM_DIR_COUNT (dbf)
- && dbf->dir[dir_index] >= 2*dbf->header->block_size;
+ && dbf->dir[dir_index] >= dbf->header->block_size;
}
/* Find a bucket for DBF that is pointed to by the bucket directory from
--
cgit v0.9.0.3

View File

@ -2,8 +2,8 @@
Summary: A GNU set of database routines which use extensible hashing Summary: A GNU set of database routines which use extensible hashing
Name: gdbm Name: gdbm
Version: 1.18 Version: 1.18.1
Release: 5%{?dist} Release: 1%{?dist}
Epoch: 1 Epoch: 1
License: GPLv3+ License: GPLv3+
URL: http://www.gnu.org/software/gdbm/ URL: http://www.gnu.org/software/gdbm/
@ -13,11 +13,8 @@ Source: http://ftp.gnu.org/gnu/gdbm/gdbm-%{version}.tar.gz
# Upstream bug http://puszcza.gnu.org.ua/bugs/?func=detailitem&item_id=151 # Upstream bug http://puszcza.gnu.org.ua/bugs/?func=detailitem&item_id=151
# Fixed in http://cvs.gnu.org.ua/viewvc/gdbm/gdbm/src/gdbmopen.c?r1=1.12&r2=1.13 # Fixed in http://cvs.gnu.org.ua/viewvc/gdbm/gdbm/src/gdbmopen.c?r1=1.12&r2=1.13
# - version 1.10 # - version 1.10
#Patch0: gdbm-1.10-zeroheaders.patch
# NOTE-WARNING file doesn't contain distro dependent largefile note now
#Patch1: gdbm-1.10-fedora.patch #Patch1: gdbm-1.10-fedora.patch
Patch2: gdbm-1.17-coverity-fixes.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: libtool BuildRequires: libtool
@ -64,7 +61,6 @@ gdbm database library. You'll also need to install the gdbm package.
%prep %prep
%setup -q %setup -q
%patch2 -p1
%build %build
%configure \ %configure \
@ -87,7 +83,7 @@ make DESTDIR=$RPM_BUILD_ROOT install
%find_lang %{name} %find_lang %{name}
# create symlinks for compatibility # create symlinks for compatibility
mkdir -p $RPM_BUILD_ROOT/%{_includedir}/gdbm mkdir -p $RPM_BUILD_ROOT/%{_includedir}/gdbm
ln -sf ../gdbm.h $RPM_BUILD_ROOT/%{_includedir}/gdbm/gdbm.h ln -sf ../gdbm.h $RPM_BUILD_ROOT/%{_includedir}/gdbm/gdbm.h
ln -sf ../ndbm.h $RPM_BUILD_ROOT/%{_includedir}/gdbm/ndbm.h ln -sf ../ndbm.h $RPM_BUILD_ROOT/%{_includedir}/gdbm/ndbm.h
ln -sf ../dbm.h $RPM_BUILD_ROOT/%{_includedir}/gdbm/dbm.h ln -sf ../dbm.h $RPM_BUILD_ROOT/%{_includedir}/gdbm/dbm.h
@ -118,9 +114,13 @@ make check
%{_libdir}/libgdbm_compat.so %{_libdir}/libgdbm_compat.so
%{_includedir}/* %{_includedir}/*
%{_infodir}/*.info* %{_infodir}/*.info*
%{_mandir}/man3/* %{_mandir}/man3/*
%changelog %changelog
* Mon Sep 23 2019 Filip Janus <fjanus@redhat.com> - 1.18.1-1
- Upstream released 1.18.1 bug(#1706639)
- Remove old patches
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.18-5 * Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.18-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (gdbm-1.18.tar.gz) = 57c7e5dc52464e97ad955e28d49fdb3557d8e3bdf280f7d3cee69539e4878f055db17cb9dd591f82fadb8fa5041a5a56d8a571d34f6e115470a3a82537f872a8 SHA512 (gdbm-1.18.1.tar.gz) = adf9d6c5bc843ff0d7f88c2a1667d509973b2d63378d0001d7e74cc10aee6ea498a4513cc88ddf78c32ba4db5cb040b2794f4f1b3338c65d9894058850e2f5ef