[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#7965) heap corruption due to returning a reference to the local variable



The attached files is derived from OpenLDAP Software. All of the modifications
to OpenLDAP Software represented in the following patch(es) were developed by
Peter-Service LLC, Moscow, Russia. Peter-Service LLC has not assigned rights
and/or interest in this work to any party. I, Leonid Yuriev am authorized by
Peter-Service LLC, my employer, to release this work under the following terms.

Peter-Service LLC hereby places the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.

https://github.com/leo-yuriev/openldap-lmdb-challenge/commit/1d29214f60300c838810b0954264550d4fc86f18

Author: Leo Yuriev <leo@yuriev.ru>
Date:   2014-10-14 14:49:25 +0400

     BUGFIX - lmdb-backend: heap corruption due to returning a
reference to the local variable.

diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c
index 06e6ad3..41c4758 100644
--- a/servers/slapd/back-mdb/dn2id.c
+++ b/servers/slapd/back-mdb/dn2id.c
@@ -346,7 +346,7 @@ mdb_dn2id(
                cursor = mc;
        } else {
                rc = mdb_cursor_open( txn, dbi, &cursor );
-               if ( rc ) return rc;
+               if ( rc ) goto done;
        }

        for (;;) {
@@ -470,7 +470,7 @@ mdb_dn2sups(
        key.mv_size = sizeof(ID);

        rc = mdb_cursor_open( txn, dbi, &cursor );
-       if ( rc ) return rc;
+       if ( rc ) goto done;

        for (;;) {
                key.mv_data = &pid;