Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 49959 invoked by uid 500); 18 Sep 2001 08:09:43 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 49948 invoked from network); 18 Sep 2001 08:09:43 -0000 From: "Mladen Turk" To: "'Greg Stein'" Cc: "'APR Dev List'" , "Ian Holsman" Subject: RE: [PATCH] apr_dbm -- db fix Date: Tue, 18 Sep 2001 10:05:07 -0700 Message-ID: <000001c14064$12032db0$5f00000a@armada> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Importance: Normal In-Reply-To: <20010917135719.C466@lyra.org> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N > -----Original Message----- > From: Greg Stein [mailto:gstein@lyra.org] > Sent: 17. rujan 2001 13:57 > To: Mladen Turk > Cc: APR Dev List > Subject: Re: [PATCH] apr_dbm -- db fix > > -1 -- this patch should not be applied. > > The change to RETURN_DATUM is wrong. The result of the NEXTKEY is placed > into "rd", and that is returned. If DB's do_nextkey is putting the result > into *pkey rather than *pnext, then *that* is the bug. But changing the > RETURN_DATUM call is wrong. > > I *know* that the apr_dbm_nextkey() function is working. If DB isn't, then > you should question the macros instead. > [Mladen Turk] Sorry but did you try to run the testdbm utility? I've tested it using db-1.85 and db-3.3.11 1. Insert some values using 'testdbm build whatever' 2. Run 'testdbm list whatever' 3. After the first record read you'll get a segfault The Berkeley DB docs are even stating that DBcursor->c_get returns key/data pair, so why would you copy data to key? Now, when I apply the patch, on db-3.3.11 I have a infinite loop. The reason for that is that data DBT must be memset to zero. Here is the complete patch. I've tested it on WIN32 using db-1.85 and db-3.3.11. If someone has some doubts I suggest him to run the testdbm and see for himself. MT. Index: apr_dbm.c =================================================================== RCS file: /home/cvspublic/apr-util/dbm/apr_dbm.c,v retrieving revision 1.27 diff -u -r1.27 apr_dbm.c --- apr_dbm.c 2001/08/29 18:34:05 1.27 +++ apr_dbm.c 2001/09/18 07:54:20 @@ -255,8 +255,13 @@ int dberr; DBT data; + memset(&data,0,sizeof(DBT)); #if DB_VER == 1 dberr = (*f->bdb->seq)(f->bdb, pkey, &data, R_NEXT); + if (dberr == RET_SPECIAL) { + pkey->data = NULL; + pkey->size = 0; + } #else if (f->curs == NULL) return APR_EINVAL; @@ -553,7 +558,7 @@ CONVERT_DATUM(ckey, pkey); rv = APR_DBM_NEXTKEY(dbm->file, ckey, rd); - RETURN_DATUM(pkey, rd); + RETURN_DATUM(pkey, ckey); REGISTER_CLEANUP(dbm, pkey);