tag 79781 notabug
close 79781
stop

Details below...

On 07/11/2025 11:10, Ray steven wrote:
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;

Static analysis tools should define lint with coreutils.

If we've already tagged something with IF_LINT, then
we've already analyzed it's use as OK.

It's better to not initialize variables to non valid values,
as then you lose the benefit of runtime UMR analysis.

thanks,
Padraig.



Reply via email to