bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible UNINIT bug within man-db gl sources


From: Lukas Javorsky
Subject: Re: Possible UNINIT bug within man-db gl sources
Date: Wed, 21 Aug 2024 08:55:17 +0200

Is this patch necessary? The elements of the structure are initialized prior to the return statement.

Since the `i`, `j`, and `count` are not really used, I feel like the SAST report I've sent can be marked as a false positive.

Do you agree?

On Sat, Aug 17, 2024 at 7:17 AM Paul Eggert <eggert@cs.ucla.edu> wrote:
On 2024-08-16 07:30, Bruno Haible wrote:
> Copying and then discarding an uninitialized value of integer
> or pointer type (i.e. not a signalling NaN (*)) is not undefined behaviour.

Although that's how typical implementations behave, the C standard says
that copying from a source variable has undefined behavior if the source
could have been declared with 'register' (i.e., it's auto and never has
its address taken). See C23 §6.3.2.1 paragraph 2. Since the code in
question is copying from such a source, its behavior is technically
undefined.

I recall running into a similar problem myself, when writing the mcel
code, though I don't recall the details.

Proposed patch attached. I daresay there's lots of other places that
would need a similar fix, assuming this one is acceptable.


--
S pozdravom/ Best regards

Lukáš Javorský

Senior Software Engineer, Core service - Databases

Red Hat

Purkyňova 115 (TPB-C)

612 00 Brno - Královo Pole

ljavorsk@redhat.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]