Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 42615 invoked from network); 19 May 2006 19:12:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 May 2006 19:12:21 -0000 Received: (qmail 78304 invoked by uid 500); 19 May 2006 19:12:20 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 78265 invoked by uid 500); 19 May 2006 19:12:19 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 78254 invoked by uid 99); 19 May 2006 19:12:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 May 2006 12:12:19 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of oscaremma@gmail.com designates 64.233.184.224 as permitted sender) Received: from [64.233.184.224] (HELO wr-out-0506.google.com) (64.233.184.224) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 May 2006 12:12:18 -0700 Received: by wr-out-0506.google.com with SMTP id i11so704219wra for ; Fri, 19 May 2006 12:11:57 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=rvk2DD9goKvqQNA+l6hWxVqdFnYOdWNI0mZahqQtBvD3VYRyGmJ7HVKuC0N3rltO4jY7+niwTf64KlpNidqYOUZr7bDtLh9AViqAxccKHTNaBn9jaK09ToXjTPUltU8534bDMlOZQmlsW/Gnd9xpbdQPunDycRyJwQJDNbROSS8= Received: by 10.64.242.10 with SMTP id p10mr1739120qbh; Fri, 19 May 2006 12:11:57 -0700 (PDT) Received: by 10.65.244.4 with HTTP; Fri, 19 May 2006 12:11:57 -0700 (PDT) Message-ID: <3ce0569d0605191211h33624c6dsf1eadee307af3a1e@mail.gmail.com> Date: Fri, 19 May 2006 15:11:57 -0400 From: "David Jones" To: dev@apr.apache.org Subject: [PATCH] Apache httpd's htdbm support program delete function fails on 64bit platform MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3805_21257028.1148065917462" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_3805_21257028.1148065917462 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Apache httpd's htdbm support program SDBM delete on 64bit fails with 'Canno= t find user'. (create,add,list still work) This is an endian issue as well since htdbm -x works on a 64bit AMD machine= , but not sparc or z/OS. dsize.apr_sdbm_datum_t in apr_sdbm.h has int dcl, but should be using apr_size_t to insure the field is not being truncated in the apr_dbm_exists->vt_sdbm_exists->apr_sdbm_fetch flow. Below is a test on a sparc 64bit build: $ bin/htdbm -c testorig name01 Enter password : Re-type password : Database testorig created. $ bin/htdbm testorig name02 Enter password : Re-type password : Database testorig updated. $ bin/htdbm -l testorig Dumping records from database -- testorig Username Comment name01 name02 Total #records : 2 $ bin/htdbm -x testorig name01 Cannot find user 'name01' in database Patch: Index: apr-util/include/apr_sdbm.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- apr-util/include/apr_sdbm.h (revision 407593) +++ apr-util/include/apr_sdbm.h (working copy) @@ -50,7 +50,7 @@ /** pointer to the data stored/retrieved */ char *dptr; /** size of data */ - int dsize; + apr_size_t dsize; } apr_sdbm_datum_t; /* The extensions used for the database files */ Update to test routine testdbm.c to check if apr_dbm_exists and apr_dbm_delete work: Index: apr-util/test/testdbm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- apr-util/test/testdbm.c (revision 407593) +++ apr-util/test/testdbm.c (working copy) @@ -190,7 +190,7 @@ line =3D (char *) apr_palloc(pool,LINEMAX); switch (act->scode) { - + case DLOOK: while (fgets(line, LINEMAX, stdin) !=3D NULL) { n =3D strlen(line) - 1; @@ -288,7 +288,9 @@ case DAUTO: { int i; + int exists =3D 0; char *valdata =3D "0123456789"; + char keydeldata[] =3D "KEYTODELETE"; fprintf(stderr, "Generating data: "); for (i =3D 0; i < 10; i++) { int j; @@ -330,6 +332,31 @@ } } fputs("OK\n", stderr); + fputs("Testing store for deletion: ", stderr); + key.dptr =3D keydeldata; + key.dsize =3D strlen(keydeldata); + rv =3D apr_dbm_store(db, key, val); + if (rv !=3D APR_SUCCESS) { + prdatum(stderr, key); + fprintf(stderr, ": "); + oops(db, rv, "store: %s", "failed"); + } + fputs("OK\n", stderr); + fputs("Testing exists: ", stderr); + exists =3D apr_dbm_exists(db, key); + if (exists =3D=3D 0) { + prdatum(stderr, key); + fprintf(stderr, ": "); + oops(db, 0, "exist: %s", "failed"); + } + fputs("OK\n", stderr); + fputs("Testing deletion: ", stderr); + if (apr_dbm_delete(db, key) !=3D APR_SUCCESS) { + prdatum(stderr, key); + fprintf(stderr, ": "); + oops(db, rv, "deletion: %s", "failed"); + } + fputs("OK\n", stderr); } break; } New testdbm.c output without patch: ./testdbm auto SDBM Generating data: OK Testing retrieval: OK Testing store for deletion: OK Testing exists: KEYTODELETE: testdbm: exist: failed With patch: ./testdbm auto SDBM Generating data: OK Testing retrieval: OK Testing store for deletion: OK Testing exists: OK Testing deletion: OK David Jones ------=_Part_3805_21257028.1148065917462 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Apache httpd's htdbm support program SDBM delete on 64bit fails with '= Cannot find user'. (create,add,list still work)
 
This is an end= ian issue as well since htdbm -x works on a 64bit AMD machine, but not spar= c or z/OS.=20
 
dsize.apr_sdbm_datum_t in apr_sdbm.h has int dcl, but should = be using apr_size_t to insure the field is not being truncated
in the ap= r_dbm_exists->vt_sdbm_exists->apr_sdbm_fetch flow.
Below is a test= on a sparc 64bit build:=20
 
$ bin/htdbm -c testorig name01
Enter password  &= nbsp;     :
Re-type password    =   :
Database testorig created.
$ bin/htdbm  testorig name02=
Enter password        :
Re-type = password      :
Database testorig updated.=20
$ bin/htdbm -l testorig
Dumping records from database -- testorig    Username        = ;            &n= bsp;   Comment
    name01
   = name02
Total #records : 2
$ bin/htdbm -x testorig name01
Cannot = find user 'name01' in database=20
 
 
 
Patch:

Index: apr-util/include/apr_sdbm.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D
--- apr-util/include/apr_sdbm.h (revision 407593)
= +++ apr-util/include/apr_sdbm.h (working copy)
@@ -50,7 +50,7 @@=20
     /** pointer to the data stored/retrieved */     char *dptr;
     /** size = of data */
-    int dsize;
+    apr_siz= e_t dsize;
 } apr_sdbm_datum_t;

 /* The extensions used for the database files */

 

 

 
Update to test routine  testdbm.c to check if apr_dbm_exi= sts and apr_dbm_delete work:


Index: apr-util/test/testdbm.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D
--- apr-util/test/testdbm.c     (= revision 407593)
+++ apr-util/test/testdbm.c     (wo= rking copy)
@@ -190,7 +190,7 @@=20
     line =3D (char *) apr_palloc(pool,LINEMAX);

     switch (act->scode) {
-
= +
     case DLOOK:
     =     while (fgets(line, LINEMAX, stdin) !=3D NULL) {
 = ;            n =3D s= trlen(line) - 1;
@@ -288,7 +288,9 @@
     case DA= UTO:
         {
            = ; int i;
+          &= nbsp; int exists =3D 0;
        =      char *valdata =3D "0123456789";
+&nbs= p;          char keydeldata[] = =3D "KEYTODELETE";
       &= nbsp;     fprintf(stderr, "Generating data: "= );
            = ; for (i =3D 0; i < 10; i++) {
      &= nbsp;          int j;
@@ -3= 30,6 +332,31 @@
         &n= bsp;       }
     = ;        }
    &n= bsp;        fputs("OK\n", stde= rr);
+           = fputs("Testing store for deletion: ", stderr);
+            key= .dptr =3D keydeldata;
+        &= nbsp;  key.dsize =3D strlen(keydeldata);
+    &= nbsp;       rv =3D apr_dbm_store(db, key, val= );
+            i= f (rv !=3D APR_SUCCESS) {
+       &nb= sp;        prdatum(stderr, key);
+            &n= bsp;   fprintf(stderr, ": ");
+   &n= bsp;            oops= (db, rv, "store: %s", "failed");
+   =          }
+   &n= bsp;        fputs("OK\n", stde= rr);
+           = fputs("Testing exists: ", stderr);
+            exi= sts =3D apr_dbm_exists(db, key);
+      &= nbsp;     if (exists =3D=3D 0) {
+   =              pr= datum(stderr, key);
+        &nb= sp;       fprintf(stderr, ": ");+            &= nbsp;   oops(db, 0, "exist: %s", "failed");
+            } <= br>+            fput= s("OK\n", stderr);
+       =      fputs("Testing deletion: ", stderr);
= +            if (apr= _dbm_delete(db, key) !=3D APR_SUCCESS) {
+     =            prdatum(stderr= , key);
+           &nbs= p;    fprintf(stderr, ": ");
+  &nbs= p;             = oops(db, rv, "deletion: %s", "failed");
+  = ;          }
+  &= nbsp;         fputs("OK\n"= ;, stderr);
         }
 =         break;
     }


 
New testdbm.c output without patch:
./testdbm auto SDBM=
Generating data: OK
Testing retrieval: OK
Testing store for delet= ion: OK
Testing exists: KEYTODELETE: testdbm: exist: faile= d

With patch:
 ./testdbm auto SDBM
Generating data: OK
Testi= ng retrieval: OK
Testing store for deletion: OK
Testing exists: OKTesting deletion: OK
 
David Jones

------=_Part_3805_21257028.1148065917462--