tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] NULL pointer dereference due to unchecked return from


From: Vincent Lefevre
Subject: Re: [Tinycc-devel] NULL pointer dereference due to unchecked return from fdopen()
Date: Mon, 28 Feb 2022 11:37:10 +0100
User-agent: Mutt/2.2.1+6 (14187faf) vl-138565 (2022-02-21)

On 2022-02-28 10:50:29 +0100, grischka wrote:
> Christian Jullien wrote:
> > Thanks,
> > This is unfortunately not the only case where returned value is not tested, 
> > just for fdopen, if maintainers agree, we can probably apply:
> > Wdyt?
> 
> The rule is, as always:  don't write code that you cannot test.

Various other error cases are probably not tested.
Has anyone checked code coverage?

Testing the code can be done once by adding "fp = NULL;" and checking
that the error is correctly handled. Otherwise, perhaps with LD_PRELOAD
to define a fdopen wrapper that will simulate an error for some calls.

> Can you?
> 
> Otherwise, can we stop suggesting sloppily crafted quick patches
> addressing non-existent problems?

fdopen() may fail. So this is a real problem. However, the check for
errors should be done on the other related function calls too.

Not checking errors may yield obscure errors in user code and/or
data loss/corruption (this happened to me with GCC, which did not
check some write errors, so that data were randomly silently missing
on NFS and my scripts were failing with errors difficult to debug).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

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