home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume8 / sp / part01 / dbm.bug < prev    next >
Encoding:
Text File  |  1987-02-19  |  1.8 KB  |  76 lines

  1. Article 770 of net.bugs.4bsd:
  2. Path: ubc-cs!ubc-ean!alberta!ihnp4!mhuxn!mhuxr!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!elsie!ado
  3. From: ado@elsie.UUCP (Arthur David Olson)
  4. Subject: 4.?bsd dbm's store(k,c) dies if (i=k.dsize+c.dsize)==1018||i==1019--FIX
  5. Date: Wed, 10-Apr-85 09:02:36 PST
  6. Date-Received: Thu, 11-Apr-85 13:03:49 PST
  7. Organization: NIH-LEC, Bethesda, MD
  8.  
  9. Index:        lib/libdbm/dbm.c Fix
  10.  
  11. Description:
  12.     4.?bsd dbm's store function misbehaves if the sum of the key data
  13.     size and content data size is either 1018 or 1019.
  14.  
  15. Repeat-By:
  16.     Compile this program with the "dbm" library:
  17.  
  18.         typedef struct {
  19.             char *    dptr;
  20.             int    dsize;
  21.         } datum;
  22.  
  23.         char    buf[1024];
  24.  
  25.         main(argc, argv)
  26.         int    argc;
  27.         char *    argv[];
  28.         {
  29.             int    result;
  30.             datum    key;
  31.             datum    content;
  32.  
  33.             key.dptr = content.dptr = buf;
  34.             key.dsize = atoi(argv[1]);
  35.             content.dsize = 0;
  36.             creat("fake.dir", 0600);
  37.             creat("fake.pag", 0600);
  38.             dbminit("fake");
  39.             result = store(key, content);
  40.             printf("%d\n", result);
  41.         }
  42.  
  43.     Then run the program.  If you use commands such as
  44.         a.out 0
  45.         a.out 1
  46.         ...
  47.         a.out 1017
  48.     things go swimmingly.  If you use commands such as
  49.         a.out 1019
  50.         a.out 1020
  51.         ...
  52.     an error message is (correctly) produced.  But if you use either
  53.     the command
  54.         a.out 1018
  55.     or
  56.         a.out 1019
  57.     things go wild.
  58.  
  59. Fix:
  60.     As usual, the trade secret status of the code involved precludes a
  61.     clearer posting.  The fix is to change one line in "dbm.c"; it
  62.     causes an error message to be produced in the 1018/1019 cases:
  63.  
  64.         #ifdef OLDVERSION
  65.             if(key.dsize+dat.dsize+2*sizeof(short) >= PBLKSIZ) {
  66.         #else
  67.             if(key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) {
  68.         #endif
  69. --
  70. Bugs is a Warner Brothers trademark
  71. --
  72.     UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
  73.     DEC, VAX and Elsie are Digital Equipment and Borden trademarks
  74.  
  75.  
  76.