Whamcloud - gitweb
AOSP: ext2simg: fix same_file() with symlinks
authorEric Biggers <ebiggers@google.com>
Thu, 23 Mar 2023 02:52:09 +0000 (02:52 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 20 May 2024 17:07:50 +0000 (13:07 -0400)
commitd553ae5bd39562bc02f791d9c353a530ca1c8a36
treeefe0de6301f6e1f401d750cd25d0e72f85a7d6fb
parente5b299064df997dc6659659db345486e0c38aadc
AOSP: ext2simg: fix same_file() with symlinks

Fix same_file() to use stat() instead of lstat() when checking the
paths, so that symlinks are dereferenced.  This is needed to be
consistent with how the paths are actually accessed later.  Otherwise,
not all cases where the input and output file are the same are detected.

Also just use the stat() result to check whether the output file exists,
instead of using a separate call to access().

Fixes: db6f320912cf ("AOSP: android: add the ext2simg tool")
Change-Id: Ie36981f9dbc19494732f518488a75fb92c0f0343
Signed-off-by: Eric Biggers <ebiggers@google.com>
From AOSP commit: 08c122f12fc231029a74c24b969e337203c7b6e2
contrib/android/ext2simg.c