mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dump2tar: Use readlinkat() unconditionally in read_symlink()
Replace the readlink() branch with readlinkat() and normalize parameters: use AT_FDCWD with filename when relname is NULL. This removes duplicate code paths while preserving behavior, including the growth loop and size limits. readlinkat() is a superset of readlink(). Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Jan Polensky <japo@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
365be71dfc
commit
6da56acf4b
@@ -655,16 +655,18 @@ static int read_symlink(struct task *task, const char *filename,
|
||||
task->opts->read_chunk_size;
|
||||
int rc = EXIT_OK;
|
||||
|
||||
/* If @relname is NULL, use @filename with AT_FDCWD. */
|
||||
if (!relname) {
|
||||
relname = filename;
|
||||
dirfd = AT_FDCWD;
|
||||
}
|
||||
|
||||
while (!is_aborted(task)) {
|
||||
buffer_make_room(buffer, currlen, false,
|
||||
task->opts->max_buffer_size);
|
||||
|
||||
cancel_enable();
|
||||
if (relname)
|
||||
actual = readlinkat(dirfd, relname, buffer->addr,
|
||||
buffer->size);
|
||||
else
|
||||
actual = readlink(filename, buffer->addr, buffer->size);
|
||||
actual = readlinkat(dirfd, relname, buffer->addr, buffer->size);
|
||||
cancel_disable();
|
||||
|
||||
if (actual == -1) {
|
||||
|
||||
Reference in New Issue
Block a user