public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jay K <jayk123@hotmail.com>
To: gcc <gcc@gcc.gnu.org>,
	"dmalcolm@redhat.com" <dmalcolm@redhat.com>,
	"mirimmad17@gmail.com" <mirimmad17@gmail.com>
Subject: Re: analyzer: implement five new warnings for misuse of POSIX
Date: Sun, 3 Jul 2022 02:46:38 +0000	[thread overview]
Message-ID: <MWHPR1401MB1951899916C1EEBFF16A23CBE6BF9@MWHPR1401MB1951.namprd14.prod.outlook.com> (raw)
In-Reply-To: <mailman.394.1656804030.3030988.gcc-patches@gcc.gnu.org>

 > check for double "close" of a FD (CWE-1341).
 > check for read/write of a closed file descriptor 
 
 These sound good but kinda non general or incomplete to me. 
 I mean, isn't the "right" thing, to disallow passing 
 a closed fd to "almost any" function?  

 But I realize "almost any" is difficult to pin down. 
  fd = open(); 
  close(fd); 
  printf("%d", fd);  

is often ok (assuming nobody reads the output, string to int,
back to close/read/write). It is any path leading to,
a long list, like close, read, write, ioctl, send, recv, etc.
and I don't know if "path leading to" is possible to model here, haven't looked, sorry.

 - Jay

       reply	other threads:[~2022-07-03  2:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.394.1656804030.3030988.gcc-patches@gcc.gnu.org>
2022-07-03  2:46 ` Jay K [this message]
2022-07-03 19:47   ` David Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR1401MB1951899916C1EEBFF16A23CBE6BF9@MWHPR1401MB1951.namprd14.prod.outlook.com \
    --to=jayk123@hotmail.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=mirimmad17@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).