Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jul 2023 17:37:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 272474] lib/libc: bcmp may give wrong results on LP64 systems
Message-ID:  <bug-272474-227-HZcbUqgaLF@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-272474-227@https.bugs.freebsd.org/bugzilla/>

index | next in thread | previous in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272474

--- Comment #5 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=4da7282a1882fc03c99591c27d44a2e6dfda364b

commit 4da7282a1882fc03c99591c27d44a2e6dfda364b
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-07-12 18:23:21 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-07-16 17:36:17 +0000

    lib/libc/string/bcmp.c: fix integer overflow bug

    bcmp() returned the number of remaining bytes when the main loop exits.
    In case of a match, this is zero, else a positive integer.  On systems
    where SIZE_MAX > INT_MAX, the implicit conversion from size_t to int in
    the return value may cause the number of remaining bytes to overflow,
    becoming zero and falsely indicating a successful comparison.

    Fix the bug by always returning 0 on equality, 1 otherwise.

    PR:             272474
    Approved by:    emaste
    Reviewed by:    imp
    MFC After:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D41011

 lib/libc/string/bcmp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
You are receiving this mail because:
You are the assignee for the bug.

help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-272474-227-HZcbUqgaLF>