public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ulfalizer at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/2753] Integer overflow in bsearch Date: Thu, 13 Nov 2014 10:13:00 -0000 [thread overview] Message-ID: <bug-2753-131-2PPJrmegvo@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-2753-131@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=2753 Ulf Magnusson <ulfalizer at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |ulfalizer at gmail dot com Resolution|WORKSFORME |--- --- Comment #5 from Ulf Magnusson <ulfalizer at gmail dot com> --- For what it's worth, here's a test case that causes bsearch() to hang when sizeof(size_t) == 4: #include <stdlib.h> #include <string.h> #define LEN 0x80000001 static int compar(const void *a, const void *b) { return *(char*)a - *(char*)b; } int main() { char *arr = malloc(LEN), key = 1; memset(arr, 0, LEN); bsearch(&key, arr, LEN, 1, compar); } The bug could be fixed by replacing '__idx = (__l + __u) / 2' with '__idx = __l + (__u - __l)/2' in bits/stdlib-bsearch.h. I don't see a good reason not to. -- You are receiving this mail because: You are on the CC list for the bug.
next parent reply other threads:[~2014-11-13 10:13 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-2753-131@http.sourceware.org/bugzilla/> 2014-11-13 10:13 ` ulfalizer at gmail dot com [this message] 2014-11-13 10:17 ` ulfalizer at gmail dot com 2014-11-25 21:54 ` neleai at seznam dot cz 2015-04-27 19:45 ` wbrad.vt at gmail dot com 2006-06-10 20:38 [Bug libc/2753] New: " greenrd at greenrd dot org 2006-06-13 15:27 ` [Bug libc/2753] " drepper at redhat dot com 2006-06-13 15:29 ` drepper at redhat dot com 2006-06-13 17:45 ` greenrd at greenrd dot org 2006-08-12 20:33 ` drepper 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-2753-131-2PPJrmegvo@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).