public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "chipitsine at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/108251] New: false positive: null dereference
Date: Thu, 29 Dec 2022 13:26:09 +0000	[thread overview]
Message-ID: <bug-108251-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108251

            Bug ID: 108251
           Summary: false positive: null dereference
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: chipitsine at gmail dot com
  Target Milestone: ---

repro steps:

git clone https://github.com/haproxy/haproxy
cd haproxy
export CC=/home/ilia/gcc/gcc-home/bin/gcc 
make TARGET=linux-glibc USE_OPENSSL=1 DEBUG_CFLAGS="-fanalyzer"

this finding is wrong

```
src/ssl_sample.c:502:34: warning: dereference of NULL '0' [CWE-476]
[-Wanalyzer-null-dereference]
  502 |         smp->data.u.sint = ((conn->flags & CO_FL_EARLY_DATA)  &&
      |                              ~~~~^~~~~~~
  'smp_fetch_ssl_fc_has_early': events 1-3
    |
    |  491 |         if (!ssl)
    |      |            ^
    |      |            |
    |      |            (1) following 'false' branch (when 'ssl' is
non-NULL)...
    |......
    |  494 |         smp->flags = 0;
    |      |         ~~~~~~~~~~~~~~
    |      |                    |
    |      |                    (2) ...to here
    |......
    |  502 |         smp->data.u.sint = ((conn->flags & CO_FL_EARLY_DATA)  &&
    |      |                              ~~~~~~~~~~~
    |      |                                  |
    |      |                                  (3) dereference of NULL
'<unknown>'
    |
```

if conn is null, we'll return here (two lines above):

```
        ssl = ssl_sock_get_ssl_object(conn);
        if (!ssl)
                return 0;
```

detailed review:
https://github.com/haproxy/haproxy/issues/1745#issuecomment-1367200781

             reply	other threads:[~2022-12-29 13:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29 13:26 chipitsine at gmail dot com [this message]
2023-01-09 19:35 ` [Bug analyzer/108251] " dmalcolm at gcc dot gnu.org
2023-01-09 19:36 ` dmalcolm at gcc dot gnu.org
2023-01-09 19:38 ` dmalcolm at gcc dot gnu.org
2023-01-09 19:39 ` dmalcolm at gcc dot gnu.org
2023-01-09 19:41 ` dmalcolm at gcc dot gnu.org
2023-01-09 19:55 ` dmalcolm at gcc dot gnu.org
2023-03-09 21:21 ` [Bug analyzer/108251] -Wanalyzer-null-dereference false positive seen in haproxy's src/ssl_sample.c cvs-commit at gcc dot gnu.org

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=bug-108251-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).