util/os_file: always use the 'grow' mechanism
authorEric Engestrom <eric.engestrom@intel.com>
Wed, 1 May 2019 10:44:16 +0000 (11:44 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Thu, 16 May 2019 11:56:25 +0000 (12:56 +0100)
commit22c1657d0552be0c558ca805c8d574e92f53c2cc
tree73425d7875600734864050615c3e35f24d7a8d51
parente04cf0b61269ca60b3260d81d94e625965d39901
util/os_file: always use the 'grow' mechanism

Use fstat() only to pre-allocate a big enough buffer.

This fixes a race where if the file grows between fstat() and read()
we would be missing the end of the file, and if the file slims down
read() would just fail.

Fixes: 316964709e21286c2af5 "util: add os_read_file() helper"
Reported-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/util/os_file.c