public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/108251] false positive: null dereference Date: Mon, 09 Jan 2023 19:39:58 +0000 [thread overview] Message-ID: <bug-108251-4-o6asAqwPZU@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108251-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108251 --- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> --- Without optimization, trunk with just -Wno-address-of-packed-member (and -fanalyzer), I get: ../../src/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c: In function ‘smp_fetch_ssl_fc_has_early’: ../../src/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:92:27: warning: dereference of NULL ‘conn’ [CWE-476] [-Wanalyzer-null-dereference] 92 | smp->data.u.sint = ((conn->flags & CO_FL_EARLY_DATA) && | ~~~~^~~~~~~ ‘smp_fetch_ssl_fc_has_early’: events 1-2 | | 78 | smp_fetch_ssl_fc_has_early(const struct arg *args, struct sample *smp, const char *kw, void *private) | | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) entry to ‘smp_fetch_ssl_fc_has_early’ |...... | 83 | conn = objt_conn(smp->sess->origin); | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (2) calling ‘objt_conn’ from ‘smp_fetch_ssl_fc_has_early’ | +--> ‘objt_conn’: events 3-4 | | 61 | static inline struct connection *objt_conn(enum obj_type *t) | | ^~~~~~~~~ | | | | | (3) entry to ‘objt_conn’ |...... | 64 | return ((void *)0); | | ~ | | | | | (4) ‘0’ is NULL | <------+ | ‘smp_fetch_ssl_fc_has_early’: events 5-8 | | 83 | conn = objt_conn(smp->sess->origin); | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (5) return of NULL to ‘smp_fetch_ssl_fc_has_early’ from ‘objt_conn’ | 84 | ssl = ssl_sock_get_ssl_object(conn); | 85 | if (!ssl) | | ~ | | | | | (6) following ‘false’ branch (when ‘ssl’ is non-NULL)... |...... | 88 | smp->flags = 0; | | ~~~~~~~~~~~~~~ | | | | | (7) ...to here |...... | 92 | smp->data.u.sint = ((conn->flags & CO_FL_EARLY_DATA) && | | ~~~~~~~~~~~ | | | | | (8) dereference of NULL ‘conn’ |
next prev parent reply other threads:[~2023-01-09 19:39 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-29 13:26 [Bug analyzer/108251] New: " chipitsine at gmail dot com 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 [this message] 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-o6asAqwPZU@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: linkBe 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).