bug#79336: [PATCH] df: fix potential null pointer dereference

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Paul Eggert <[email protected]> writes:

> On 2025-08-28 18:45, yubiao hu wrote:
>> * src/df.c (get_dev): Fix potential null pointer dereference
>> - Avoid dereferencing stat_file when both device and
>>   mount_point are NULL
>> - Handle allocation failure for cell when mount_point
>>   is NULL
>
> Why is this patch needed? Can you give an example df invocation in
> which mount_point is null there? As far as I can see, that cannot
> happen.

That was my understanding as well. Since preceding that section there
is:

    /* If MOUNT_POINT is null, then the file system is not mounted, and this
       program reports on the file system that the special file is on.
       It would be better to report on the unmounted file system,
       but statfs doesn't do that on most systems.  */
    if (!stat_file)
      stat_file = mount_point ? mount_point : device;

I don't see why we would have a mount entry if both MOUNT_POINT and
DEVICE are NULL.

Collin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.