[apr-util] 07/09: Fix handling of gdbm_errno in gdbm driver

Stefan Fritsch sf at moszumanska.debian.org
Sun Feb 25 11:46:03 UTC 2018


This is an automated email from the git hooks/post-receive script.

sf pushed a commit to branch master
in repository apr-util.

commit 2a1a659227ff0ff5b9ceae6dcbcfec115ee43ba6
Author: Stefan Fritsch <sf at sfritsch.de>
Date:   Sun Feb 25 12:33:27 2018 +0100

    Fix handling of gdbm_errno in gdbm driver
    
    We must only look at gdbm_errno if the return code of the gdbm function
    tells us to look there.
---
 debian/changelog                       |  1 +
 debian/patches/fix_gdbm_error_handling | 79 ++++++++++++++++++++++++++++++++++
 debian/patches/series                  |  1 +
 3 files changed, 81 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index ece2227..d158876 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ apr-util (1.6.1-2) UNRELEASED; urgency=medium
 
   * Avoid empty build target, fixes FTBFS. Thanks to Niels Thykier for the
     patch. Closes: #890108
+  * Fix handling of gdbm_errno in gdbm driver. Closes: #889170
   * Bump debhelper compat level to 11 and drop deprecated autotools-dev
     sequence. Thanks to Niels Thykier for the patch.
   * Bump Standards-Version (no changes)
diff --git a/debian/patches/fix_gdbm_error_handling b/debian/patches/fix_gdbm_error_handling
new file mode 100644
index 0000000..92a4738
--- /dev/null
+++ b/debian/patches/fix_gdbm_error_handling
@@ -0,0 +1,79 @@
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=889170
+# needs to be submitted upstream
+--- apr-util.orig/dbm/apr_dbm_gdbm.c
++++ apr-util/dbm/apr_dbm_gdbm.c
+@@ -36,13 +36,22 @@
+ static apr_status_t g2s(int gerr)
+ {
+     if (gerr == -1) {
+-        /* ### need to fix this */
+-        return APR_EGENERAL;
++        return APR_OS_START_USEERR + gdbm_errno;
+     }
+ 
+     return APR_SUCCESS;
+ }
+ 
++static apr_status_t gdat2s(datum d)
++{
++    if (d.dptr == NULL) {
++        return APR_OS_START_USEERR + gdbm_errno;
++    }
++
++    return APR_SUCCESS;
++}
++
++
+ static apr_status_t datum_cleanup(void *dptr)
+ {
+     if (dptr)
+@@ -55,19 +64,15 @@ static apr_status_t set_error(apr_dbm_t
+ {
+     apr_status_t rv = APR_SUCCESS;
+ 
+-    /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */
+-
+-    if ((dbm->errcode = gdbm_errno) == GDBM_NO_ERROR) {
++    if (dbm_said == APR_SUCCESS) {
++        dbm->errcode = GDBM_NO_ERROR;
+         dbm->errmsg = NULL;
+     }
+     else {
++        dbm->errcode = dbm_said;
+         dbm->errmsg = gdbm_strerror(gdbm_errno);
+-        rv = APR_EGENERAL;        /* ### need something better */
+     }
+ 
+-    /* captured it. clear it now. */
+-    gdbm_errno = GDBM_NO_ERROR;
+-
+     return rv;
+ }
+ 
+@@ -144,7 +149,7 @@ static apr_status_t vt_gdbm_fetch(apr_db
+ 
+     /* store the error info into DBM, and return a status code. Also, note
+        that *pvalue should have been cleared on error. */
+-    return set_error(dbm, APR_SUCCESS);
++    return set_error(dbm, gdat2s(rd));
+ }
+ 
+ static apr_status_t vt_gdbm_store(apr_dbm_t *dbm, apr_datum_t key,
+@@ -203,7 +208,7 @@ static apr_status_t vt_gdbm_firstkey(apr
+                                   apr_pool_cleanup_null);
+ 
+     /* store any error info into DBM, and return a status code. */
+-    return set_error(dbm, APR_SUCCESS);
++    return set_error(dbm, gdat2s(rd));
+ }
+ 
+ static apr_status_t vt_gdbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey)
+@@ -223,7 +228,7 @@ static apr_status_t vt_gdbm_nextkey(apr_
+                                   apr_pool_cleanup_null);
+ 
+     /* store any error info into DBM, and return a status code. */
+-    return set_error(dbm, APR_SUCCESS);
++    return set_error(dbm, gdat2s(rd));
+ }
+ 
+ static void vt_gdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data)
diff --git a/debian/patches/series b/debian/patches/series
index 9962a8f..f1d8f4c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,3 +10,4 @@ test_verbose
 fix_doxygen_inputdir
 support_mariadb.patch
 doxygen_no_ful_path_names.patch
+fix_gdbm_error_handling

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-apache/apr-util.git



More information about the Pkg-apache-commits mailing list