Skip to content

file descriptor cleanup in copy_recursive_fd_to_fd() might be incorrect #2002

@eriksjolund

Description

@eriksjolund

srcfd and destfd are declared like this:

crun/src/libcrun/utils.c

Lines 2195 to 2196 in d0c1224

cleanup_close int srcfd = -1;
cleanup_close int destfd = -1;

I'm looking at this code:

crun/src/libcrun/utils.c

Lines 2250 to 2259 in d0c1224

#ifdef HAVE_FGETXATTR
ret = (int) copy_xattr (srcfd, destfd, de->d_name, de->d_name, err);
if (UNLIKELY (ret < 0))
return ret;
#endif
ret = copy_recursive_fd_to_fd (srcfd, destfd, de->d_name, de->d_name, err);
srcfd = destfd = -1;
if (UNLIKELY (ret < 0))
return ret;

Let us compare line 2253 with line 2259

srcfd and destfd are set to -1 in line 2257.

This impacts line 2259 but not line 2253.

I'm not sure why srcfd and destfd are closed in the return on line 2253 but not in the return on line 2259.

Is there a bug here?

(Sorry for the sketchy bug report)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions