public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug build/26779] New: benign use after realloc at localealias.c:329 Date: Fri, 23 Oct 2020 17:12:16 +0000 [thread overview] Message-ID: <bug-26779-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=26779 Bug ID: 26779 Summary: benign use after realloc at localealias.c:329 Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: build Assignee: unassigned at sourceware dot org Reporter: msebor at gmail dot com CC: carlos at redhat dot com Target Milestone: --- Testing a GCC 11 enhancement to detect invalid uses of freed pointers exposes the following (benign) bug in localealias. A successful call to realloc renders its argument indeterminate, even when it doesn't result in moving the object. The affected code uses the indeterminate pointer to detect whether the call resulted in moving the object. Converting the pointers to intptr_t and performing the equality test on those avoids the warning. char *new_pool = (char *) realloc (string_space, new_size); if (new_pool == NULL) goto out; if (__builtin_expect (string_space != new_pool, 0)) and the warning is: localealias.c: In function ‘read_alias_file’: localealias.c:329:58: warning: statement uses a freed pointer [-Wuse-after-free=] 329 | if (__builtin_expect (string_space != new_pool, 0)) | ~~~~~~~~~~~~~^~~~~~~~~~~ localealias.c:325:49: note: freed by ‘realloc’ here 325 | char *new_pool = (char *) realloc (string_space, new_size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ localealias.c:329:26: warning: statement uses a freed pointer [-Wuse-after-free=] 329 | if (__builtin_expect (string_space != new_pool, 0)) | ^ localealias.c:325:49: note: freed by ‘realloc’ here 325 | char *new_pool = (char *) realloc (string_space, new_size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2020-10-23 17:12 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-23 17:12 msebor at gmail dot com [this message] 2020-10-23 21:14 ` [Bug build/26779] " msebor at gmail dot com 2020-10-27 21:21 ` msebor at gmail dot com 2020-10-27 21:41 ` msebor at gmail dot com 2022-01-12 17:16 ` msebor at gmail dot com 2022-01-12 17:20 ` msebor at gmail dot com 2022-01-14 0:28 ` msebor at gmail dot com 2022-01-26 17:43 ` msebor at gmail dot com 2022-01-26 20:24 ` carlos at redhat dot com 2022-02-09 14:05 ` vvinayag at arm dot com 2022-02-09 14:59 ` schwab@linux-m68k.org 2022-02-09 16:13 ` vvinayag at arm dot com 2024-01-11 9:33 ` fweimer at redhat dot com
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-26779-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.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).