Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Jan 2026 02:23:12 +0000
From:      Ahmad Khalifa <vexeduxr@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9b2478f60bfd - main - ng_tty: avoid the sign extention of char
Message-ID:  <695c7210.44db0.1fed2d7b@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by vexeduxr:

URL: https://cgit.FreeBSD.org/src/commit/?id=9b2478f60bfda663c84b48e272a2293159e1b0a0

commit 9b2478f60bfda663c84b48e272a2293159e1b0a0
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-06 02:07:29 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-06 02:10:11 +0000

    ng_tty: avoid the sign extention of char
    
    When c is compared to sc->hotchar, both undergo integer promotion, which
    can lead to c being sign extended. Fix this by casting c to an unsigned
    char.
    
    Reviewed by:    kevans
    MFC after:      5 days
    Differential Revision:  https://reviews.freebsd.org/D54544
---
 sys/netgraph/ng_tty.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/netgraph/ng_tty.c b/sys/netgraph/ng_tty.c
index 0e3230a66f66..200a72336110 100644
--- a/sys/netgraph/ng_tty.c
+++ b/sys/netgraph/ng_tty.c
@@ -489,7 +489,8 @@ ngt_rint(struct tty *tp, char c, int flags)
 	m->m_pkthdr.len++;
 
 	/* Ship off mbuf if it's time */
-	if (sc->hotchar == -1 || c == sc->hotchar || m->m_len >= MHLEN) {
+	if (sc->hotchar == -1 || (u_char)c == sc->hotchar ||
+	    m->m_len >= MHLEN) {
 		sc->m = NULL;
 		NG_SEND_DATA_ONLY(error, sc->hook, m);	/* Will queue */
 	}


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?695c7210.44db0.1fed2d7b>