From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A31693858D32; Mon, 22 Jan 2024 19:54:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A31693858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1705953265; bh=hY8davZVs22FjxmnTNcAsAQj88jEXE0OxAEXPVNrs6s=; h=From:To:Subject:Date:From; b=TeAeptOZiIPvIyTtNbGFp0hr5lslT8uUQFXLqunxsG8WV7qgT1HyOdzLqY+Omp7z7 3WBjTN6hT3ROBZPtnT2VjwDD6xbjBLz1D4DHraLNz2cTeZARAndnvcUYWINUTeypnq WKtdCoj+XsXrU/RXDp8X1a5d6zJwy2JCVZ41Yvlw= From: "xry111 at xry111 dot site" To: glibc-bugs@sourceware.org Subject: [Bug libc/31276] New: Wrong condition for heap allocation in qsort_r Date: Mon, 22 Jan 2024 19:54:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.39 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at xry111 dot site 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31276 Bug ID: 31276 Summary: Wrong condition for heap allocation in qsort_r Product: glibc Version: 2.39 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: xry111 at xry111 dot site CC: drepper.fsp at gmail dot com Target Milestone: --- /* Align to the maximum size used by the swap optimization. */ _Alignas (uint64_t) char tmp[QSORT_STACK_SIZE]; size_t total_size =3D total_elems * size; char *buf; if (size > INDIRECT_SORT_SIZE_THRES) total_size =3D 2 * total_elems * sizeof (void *) + size; if (total_size < sizeof buf) buf =3D tmp; else { /* allocate buf on heap ... */ } Here "sizeof buf" is the size of a pointer, but (obviously?) we want QSORT_STACK_SIZE here, i.e. "sizeof tmp". --=20 You are receiving this mail because: You are on the CC list for the bug.=