diff options
| -rw-r--r-- | meta/recipes-support/apr/apr-util/0001-Fix-error-handling-in-gdbm.patch | 135 | ||||
| -rw-r--r-- | meta/recipes-support/apr/apr-util_1.6.1.bb | 1 |
2 files changed, 136 insertions, 0 deletions
diff --git a/meta/recipes-support/apr/apr-util/0001-Fix-error-handling-in-gdbm.patch b/meta/recipes-support/apr/apr-util/0001-Fix-error-handling-in-gdbm.patch new file mode 100644 index 0000000000..57e7453312 --- /dev/null +++ b/meta/recipes-support/apr/apr-util/0001-Fix-error-handling-in-gdbm.patch | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | From 6b638fa9afbeb54dfa19378e391465a5284ce1ad Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Changqing Li <changqing.li@windriver.com> | ||
| 3 | Date: Wed, 12 Sep 2018 17:16:36 +0800 | ||
| 4 | Subject: [PATCH] Fix error handling in gdbm | ||
| 5 | |||
| 6 | Only check for gdbm_errno if the return value of the called gdbm_* | ||
| 7 | function says so. This fixes apr-util with gdbm 1.14, which does not | ||
| 8 | seem to always reset gdbm_errno. | ||
| 9 | |||
| 10 | Also make the gdbm driver return error codes starting with | ||
| 11 | APR_OS_START_USEERR instead of always returning APR_EGENERAL. This is | ||
| 12 | what the berkleydb driver already does. | ||
| 13 | |||
| 14 | Also ensure that dsize is 0 if dptr == NULL. | ||
| 15 | |||
| 16 | Upstream-Status: Backport[https://svn.apache.org/viewvc? | ||
| 17 | view=revision&revision=1825311] | ||
| 18 | |||
| 19 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
| 20 | --- | ||
| 21 | dbm/apr_dbm_gdbm.c | 47 +++++++++++++++++++++++++++++------------------ | ||
| 22 | 1 file changed, 29 insertions(+), 18 deletions(-) | ||
| 23 | |||
| 24 | diff --git a/dbm/apr_dbm_gdbm.c b/dbm/apr_dbm_gdbm.c | ||
| 25 | index 749447a..1c86327 100644 | ||
| 26 | --- a/dbm/apr_dbm_gdbm.c | ||
| 27 | +++ b/dbm/apr_dbm_gdbm.c | ||
| 28 | @@ -36,13 +36,25 @@ | ||
| 29 | static apr_status_t g2s(int gerr) | ||
| 30 | { | ||
| 31 | if (gerr == -1) { | ||
| 32 | - /* ### need to fix this */ | ||
| 33 | - return APR_EGENERAL; | ||
| 34 | + if (gdbm_errno == GDBM_NO_ERROR) | ||
| 35 | + return APR_SUCCESS; | ||
| 36 | + return APR_OS_START_USEERR + gdbm_errno; | ||
| 37 | } | ||
| 38 | |||
| 39 | return APR_SUCCESS; | ||
| 40 | } | ||
| 41 | |||
| 42 | +static apr_status_t gdat2s(datum d) | ||
| 43 | +{ | ||
| 44 | + if (d.dptr == NULL) { | ||
| 45 | + if (gdbm_errno == GDBM_NO_ERROR || gdbm_errno == GDBM_ITEM_NOT_FOUND) | ||
| 46 | + return APR_SUCCESS; | ||
| 47 | + return APR_OS_START_USEERR + gdbm_errno; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + return APR_SUCCESS; | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | static apr_status_t datum_cleanup(void *dptr) | ||
| 54 | { | ||
| 55 | if (dptr) | ||
| 56 | @@ -53,22 +65,15 @@ static apr_status_t datum_cleanup(void *dptr) | ||
| 57 | |||
| 58 | static apr_status_t set_error(apr_dbm_t *dbm, apr_status_t dbm_said) | ||
| 59 | { | ||
| 60 | - apr_status_t rv = APR_SUCCESS; | ||
| 61 | |||
| 62 | - /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */ | ||
| 63 | + dbm->errcode = dbm_said; | ||
| 64 | |||
| 65 | - if ((dbm->errcode = gdbm_errno) == GDBM_NO_ERROR) { | ||
| 66 | + if (dbm_said == APR_SUCCESS) | ||
| 67 | dbm->errmsg = NULL; | ||
| 68 | - } | ||
| 69 | - else { | ||
| 70 | - dbm->errmsg = gdbm_strerror(gdbm_errno); | ||
| 71 | - rv = APR_EGENERAL; /* ### need something better */ | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - /* captured it. clear it now. */ | ||
| 75 | - gdbm_errno = GDBM_NO_ERROR; | ||
| 76 | + else | ||
| 77 | + dbm->errmsg = gdbm_strerror(dbm_said - APR_OS_START_USEERR); | ||
| 78 | |||
| 79 | - return rv; | ||
| 80 | + return dbm_said; | ||
| 81 | } | ||
| 82 | |||
| 83 | /* -------------------------------------------------------------------------- | ||
| 84 | @@ -107,7 +112,7 @@ static apr_status_t vt_gdbm_open(apr_dbm_t **pdb, const char *pathname, | ||
| 85 | NULL); | ||
| 86 | |||
| 87 | if (file == NULL) | ||
| 88 | - return APR_EGENERAL; /* ### need a better error */ | ||
| 89 | + return APR_OS_START_USEERR + gdbm_errno; /* ### need a better error */ | ||
| 90 | |||
| 91 | /* we have an open database... return it */ | ||
| 92 | *pdb = apr_pcalloc(pool, sizeof(**pdb)); | ||
| 93 | @@ -141,10 +146,12 @@ static apr_status_t vt_gdbm_fetch(apr_dbm_t *dbm, apr_datum_t key, | ||
| 94 | if (pvalue->dptr) | ||
| 95 | apr_pool_cleanup_register(dbm->pool, pvalue->dptr, datum_cleanup, | ||
| 96 | apr_pool_cleanup_null); | ||
| 97 | + else | ||
| 98 | + pvalue->dsize = 0; | ||
| 99 | |||
| 100 | /* store the error info into DBM, and return a status code. Also, note | ||
| 101 | that *pvalue should have been cleared on error. */ | ||
| 102 | - return set_error(dbm, APR_SUCCESS); | ||
| 103 | + return set_error(dbm, gdat2s(rd)); | ||
| 104 | } | ||
| 105 | |||
| 106 | static apr_status_t vt_gdbm_store(apr_dbm_t *dbm, apr_datum_t key, | ||
| 107 | @@ -201,9 +208,11 @@ static apr_status_t vt_gdbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey) | ||
| 108 | if (pkey->dptr) | ||
| 109 | apr_pool_cleanup_register(dbm->pool, pkey->dptr, datum_cleanup, | ||
| 110 | apr_pool_cleanup_null); | ||
| 111 | + else | ||
| 112 | + pkey->dsize = 0; | ||
| 113 | |||
| 114 | /* store any error info into DBM, and return a status code. */ | ||
| 115 | - return set_error(dbm, APR_SUCCESS); | ||
| 116 | + return set_error(dbm, gdat2s(rd)); | ||
| 117 | } | ||
| 118 | |||
| 119 | static apr_status_t vt_gdbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey) | ||
| 120 | @@ -221,9 +230,11 @@ static apr_status_t vt_gdbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey) | ||
| 121 | if (pkey->dptr) | ||
| 122 | apr_pool_cleanup_register(dbm->pool, pkey->dptr, datum_cleanup, | ||
| 123 | apr_pool_cleanup_null); | ||
| 124 | + else | ||
| 125 | + pkey->dsize = 0; | ||
| 126 | |||
| 127 | /* store any error info into DBM, and return a status code. */ | ||
| 128 | - return set_error(dbm, APR_SUCCESS); | ||
| 129 | + return set_error(dbm, gdat2s(rd)); | ||
| 130 | } | ||
| 131 | |||
| 132 | static void vt_gdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data) | ||
| 133 | -- | ||
| 134 | 2.7.4 | ||
| 135 | |||
diff --git a/meta/recipes-support/apr/apr-util_1.6.1.bb b/meta/recipes-support/apr/apr-util_1.6.1.bb index 88b4300f9d..12d71cbb68 100644 --- a/meta/recipes-support/apr/apr-util_1.6.1.bb +++ b/meta/recipes-support/apr/apr-util_1.6.1.bb | |||
| @@ -13,6 +13,7 @@ SRC_URI = "${APACHE_MIRROR}/apr/${BPN}-${PV}.tar.gz \ | |||
| 13 | file://configfix.patch \ | 13 | file://configfix.patch \ |
| 14 | file://configure_fixes.patch \ | 14 | file://configure_fixes.patch \ |
| 15 | file://run-ptest \ | 15 | file://run-ptest \ |
| 16 | file://0001-Fix-error-handling-in-gdbm.patch \ | ||
| 16 | " | 17 | " |
| 17 | 18 | ||
| 18 | SRC_URI[md5sum] = "bd502b9a8670a8012c4d90c31a84955f" | 19 | SRC_URI[md5sum] = "bd502b9a8670a8012c4d90c31a84955f" |
