Hello Coreutils maintainers,

I found a potential issue in the `copy_internal` function in `src/copy.c`.

Issue Summary
-------------
In lines 1641–1642, the variables `src_mode` and `dst_mode` are defined.
If `#ifdef lint` is not defined, these two variables are uninitialized.

In the `else` branch at line 1693, they are also not explicitly
initialized,
but `src_mode` is used later at lines 1707 and 1745, among other places.

It needs to be confirmed whether this constitutes using the variables
before they are initialized, which could lead to undefined behavior.

Suggested Action
----------------
- Review the relevant code paths to ensure `src_mode` and `dst_mode`
  are properly initialized before use.
- Consider initializing them at declaration to avoid undefined behavior:

    mode_t src_mode = 0;
    mode_t dst_mode = 0;

Thanks for your time and for maintaining Coreutils.

Best regards,
CheckScope

Reply via email to