Bug#383417: cdb_seek returns incorrect data length
I'm forwarding this bug report to the members of bug#299026, `ITP: tinycdb'. On August 17, 2006 at 3:06PM +0900, ueno (at unixuser.org) wrote: > Package: tinycdb > Version: 0.74-1 > Tags: patch > > If dlenp arg of cdb_seek point to the integer variable whose value is 0, > cdb_seek does not set dlenp correctly. This behavior is not documented > and I think it is unintended. Due to this, the dbskkd-cdb package > compiled with gcc-4.0 does not work well. > > To reproduce > > $ echo "+3,5:one->Hello\n" | cdbmake test.cdb test.cdb.tmp or use $ /bin/echo -e "+3,5:one->Hello\n" | cdbmake test.cdb test.cdb.tmp if your shell's `echo' doesn't enable interpretation of backslash escapes. > $ gcc -o testcdb testcdb.c -lcdb > $ ./testcdb ./test.cdb one > dlen = 0 # <- it should be 5 > $ cat testcdb.c > #include > #include > #include > #include > #include > #include > #include > > int main (int argc, char **argv) > { > int fd, ret; > const char *key; > unsigned klen, dlen = 0; // if dlen = 1, it works as expected > > assert (argc == 3); > fd = open (argv[1], O_RDONLY); > if (fd == -1) > { > perror ("open"); > return 1; > } > > key = argv[2]; > klen = strlen (key); > ret = cdb_seek (fd, key, klen, &dlen); > if (ret == -1) > return 1; > else if (ret == 0) > printf ("not found"); > else > printf ("dlen = %d\n", dlen); > > return 0; > } > > Here is a patch to fix it > > --- cdb_seek.c~ 2006-08-17 15:02:16.0 +0900 > +++ cdb_seek.c2006-08-17 15:02:43.0 +0900 > @@ -75,7 +75,7 @@ > /* read the key from file and compare with wanted */ > unsigned l = klen, c; > const char *k = (const char*)key; > - if (*dlenp) > + if (dlenp) > *dlenp = cdb_unpack(rbuf + 4); /* save value length */ > for(;;) { > if (!l) /* the whole key read and matches, return */ > > Regards, > -- > Daiki Ueno Daiki, thanks for your report. This bug causes my packages dbskkd-cdb and skksearch unusable. I'm thinking about applying workaround patches to dbskkd-cdb and skksearch due to this bug for the moment. Anyway, I hope this bug will be fixed shortly... Michael, could you fix this bug in tinycdb 0.76? Could anyone update the Debian tinycdb package? Thanks, -- Tatsuya Kinoshita pgpHxivJ8MNKX.pgp Description: PGP signature
Bug#383417: cdb_seek returns incorrect data length
Tatsuya Kinoshita wrote: > I'm forwarding this bug report to the members of bug#299026, `ITP: tinycdb'. > [] >> --- cdb_seek.c~ 2006-08-17 15:02:16.0 +0900 >> +++ cdb_seek.c 2006-08-17 15:02:43.0 +0900 >> @@ -75,7 +75,7 @@ >> /* read the key from file and compare with wanted */ >> unsigned l = klen, c; >> const char *k = (const char*)key; >> -if (*dlenp) >> +if (dlenp) >>*dlenp = cdb_unpack(rbuf + 4); /* save value length */ >> for(;;) { >>if (!l) /* the whole key read and matches, return */ Yeah, it's a typo. Funny we never hit it before - well, I myself don't use cdb_seek() interface, preferring cdb_find(), so it's not very surprizing. [] > Daiki, thanks for your report. > > This bug causes my packages dbskkd-cdb and skksearch unusable. > I'm thinking about applying workaround patches to dbskkd-cdb and > skksearch due to this bug for the moment. Anyway, I hope this bug > will be fixed shortly... > > Michael, could you fix this bug in tinycdb 0.76? Could anyone > update the Debian tinycdb package? Yeah, fixed in cvs, I'll refresh 0.76-pre tarball on my site shortly. But the question with the upload remains. You reminded me that I'm still not become a DD, and still didn't find anyone to upload the thing. Lemme try again... ;) /mjt -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bug#383417: cdb_seek returns incorrect data length
Package: tinycdb Version: 0.74-1 Tags: patch If dlenp arg of cdb_seek point to the integer variable whose value is 0, cdb_seek does not set dlenp correctly. This behavior is not documented and I think it is unintended. Due to this, the dbskkd-cdb package compiled with gcc-4.0 does not work well. To reproduce $ echo "+3,5:one->Hello\n" | cdbmake test.cdb test.cdb.tmp $ gcc -o testcdb testcdb.c -lcdb $ ./testcdb ./test.cdb one dlen = 0 # <- it should be 5 $ cat testcdb.c #include #include #include #include #include #include #include int main (int argc, char **argv) { int fd, ret; const char *key; unsigned klen, dlen = 0; // if dlen = 1, it works as expected assert (argc == 3); fd = open (argv[1], O_RDONLY); if (fd == -1) { perror ("open"); return 1; } key = argv[2]; klen = strlen (key); ret = cdb_seek (fd, key, klen, &dlen); if (ret == -1) return 1; else if (ret == 0) printf ("not found"); else printf ("dlen = %d\n", dlen); return 0; } Here is a patch to fix it --- cdb_seek.c~ 2006-08-17 15:02:16.0 +0900 +++ cdb_seek.c 2006-08-17 15:02:43.0 +0900 @@ -75,7 +75,7 @@ /* read the key from file and compare with wanted */ unsigned l = klen, c; const char *k = (const char*)key; - if (*dlenp) + if (dlenp) *dlenp = cdb_unpack(rbuf + 4); /* save value length */ for(;;) { if (!l) /* the whole key read and matches, return */ Regards, -- Daiki Ueno -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]