Skip to content
Snippets Groups Projects
Commit d49134e6 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

strListReadFile() now returns NULL on any file read failure

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).
parent 357fd0cb
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment