Changeset 20976

Show
Ignore:
Timestamp:
27.11.2009 16:56:24 (10 years ago)
Author:
mdewsnip
Message:

Added a safety check provided by Andrew Brooks (University of Dundee) for ensuring that a database with the wrong byte order for the machine cannot be opened for writing. (The byte swapping code that I did has only been done for reading, not writing).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/common-src/packages/gdbm/gdbm-1.8.3/gdbmopen.c

    r18097 r20976  
    381381      wrong_endianness = (partial_header.header_magic == 0xCE9A5713); 
    382382 
     383      // GREENSTONE CUSTOMISATION (thanks to Andrew Brooks): prevent write access to wrong-byte-order databases 
     384      if (wrong_endianness && ((flags & GDBM_OPENMASK) != GDBM_READER)) 
     385      { 
     386        gdbm_close (dbf); 
     387        gdbm_errno = GDBM_CANT_BE_WRITER; 
     388        return NULL; 
     389      } 
     390 
    383391      // GREENSTONE CUSTOMISATION: Swap each value in the partial header if the GDBM file is the wrong endianness 
    384392      if (wrong_endianness)