Skip to content
  • Rob Swindell's avatar
    d49134e6
    strListReadFile() now returns NULL on any file read failure · d49134e6
    Rob Swindell authored
    Previously, the partially-read lines would be returned in an allocated
    string list. This is a suspected cause of issue #791: even though the file was
    successfully opened exclusively (using sopen... SH_DENYRW), it's possible that
    Samba had already allowed another client or local process to open the same
    file, but is now a denying read (most likely, the first read). As Deuce
    pointed out, the xpdev *nix implementation of sopen() locks the region/record
    of the entire file. So before this change, strListReadFile() might fail on
    the first read, and a function that uses iniFileRead() to modify the contents
    of an ini file, might end up writing back the empty list (with added keys),
    thus deleting all the existing content of the file.
    
    Also in this change:
    - Eliminated the unnecessary local/wrapped str_list_read_file() function.
    - Elminate unecessary null-before-free check
    - Fixed potential memory leak upon malloc failure (the potentially-allocated
      list wasn't freed).
    d49134e6
    strListReadFile() now returns NULL on any file read failure
    Rob Swindell authored
    Previously, the partially-read lines would be returned in an allocated
    string list. This is a suspected cause of issue #791: even though the file was
    successfully opened exclusively (using sopen... SH_DENYRW), it's possible that
    Samba had already allowed another client or local process to open the same
    file, but is now a denying read (most likely, the first read). As Deuce
    pointed out, the xpdev *nix implementation of sopen() locks the region/record
    of the entire file. So before this change, strListReadFile() might fail on
    the first read, and a function that uses iniFileRead() to modify the contents
    of an ini file, might end up writing back the empty list (with added keys),
    thus deleting all the existing content of the file.
    
    Also in this change:
    - Eliminated the unnecessary local/wrapped str_list_read_file() function.
    - Elminate unecessary null-before-free check
    - Fixed potential memory leak upon malloc failure (the potentially-allocated
      list wasn't freed).
Loading