]> arthur.barton.de Git - bup.git/commit
metadata: fix symlink stat() vs. readlink() race
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 31 Dec 2020 22:29:58 +0000 (23:29 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 30 May 2021 16:24:40 +0000 (11:24 -0500)
commit03b9ae219db65e7bdfa7e7669761889dfdf1f591
treed4bbc7dc1dd0f8b4e0f36c52c4b8aa0dae71d8b7
parent80d9c9953a5d482df59afe8e4011bf5ef8d1bdec
metadata: fix symlink stat() vs. readlink() race

We might stat() the file and get some size, but by the time
we readlink() the link has changed and the size is something
else.

Arguably, we can't really avoid races here if we don't have
a consistent snapshot of the filesystem to save, however, in
this case we later get an assertion failure when the data is
read back from the index (or repo), and it's easy to avoid.

Set the size from the actually recorded symlink target.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py