From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BEDC2398B420; Fri, 23 Oct 2020 17:12:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BEDC2398B420 From: "msebor at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: build X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2020 17:12:16 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26779 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 expos= es the following (benign) bug in localealias. A successful call to realloc renders its argument indeterminate, even when it doesn't result in moving t= he 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 =3D (char *) realloc (string_space, new_size); if (new_pool =3D=3D NULL) goto out; if (__builtin_expect (string_space !=3D new_pool, 0)) and the warning is: localealias.c: In function =E2=80=98read_alias_file=E2=80=99: localealias.c:329:58: warning: statement uses a freed pointer [-Wuse-after-free=3D] 329 | if (__builtin_expect (string_space !=3D new_p= ool, 0)) | ~~~~~~~~~~~~~^~~~~~~~~~~ localealias.c:325:49: note: freed by =E2=80=98realloc=E2=80=99 here 325 | char *new_pool =3D (char *) realloc (string_s= pace, new_size); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ localealias.c:329:26: warning: statement uses a freed pointer [-Wuse-after-free=3D] 329 | if (__builtin_expect (string_space !=3D new_p= ool, 0)) | ^ localealias.c:325:49: note: freed by =E2=80=98realloc=E2=80=99 here 325 | char *new_pool =3D (char *) realloc (string_s= pace, new_size); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --=20 You are receiving this mail because: You are on the CC list for the bug.=