dmidecode-devel
[Top][All Lists]
Advanced

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

Re: [dmidecode] [PATCH] dmioem: Fix segmentation fault in dmi_hp_240_att


From: Jean Delvare
Subject: Re: [dmidecode] [PATCH] dmioem: Fix segmentation fault in dmi_hp_240_attr()
Date: Wed, 7 Sep 2022 11:15:29 +0200

Hi Jerry,

On Mon, 8 Aug 2022 12:46:20 -0600, Jerry Hoemann wrote:
> My concerns are at a lower level.  There appears to be a difference in
> interpretation between Linux and Free BSD tool chain on whether passing
> a NULL as format is legal.  I did a quick read of the fprintf function
> in the Ansi C 99 standard and I'm of the believe that NULL is not legal.

You are right, NULL is not legal in this context. BSD is strict and
correct, glibc is (IMHO) too permissive.

> But even if my interpretation is incorrect, there is still a difference
> between the two and I am not going to be testing under Free BSD.
> So, I'd probably go ahead an proactively change functions like
> pr_handle_name, pr_attr, etc., to check format like pr_list_start does
> to protect against this type of issue getting hit in the future.

I tend to prefer the other way, that is, find such problem at
compilation time (with the compiler itself, or a static code analyzer)
and get the source code right. I don't like checking at run-time for
errors that are simply not supposed to happen if the code is right.

(And I know not all developers think like that, and I understand their
reasoning, but personally I prefer fixing problems where they are than
catching them later, because the overall cost is much smaller.)

-- 
Jean Delvare
SUSE L3 Support



reply via email to

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