Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/sdpquery sdpquery: fix undefined behavior when calli...



details:   https://anonhg.NetBSD.org/src/rev/8d8c1c005dd6
branches:  trunk
changeset: 1023144:8d8c1c005dd6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 27 17:41:39 2021 +0000

description:
sdpquery: fix undefined behavior when calling ctype functions

lint says: warning: argument to 'function from <ctype.h>' must be cast
to 'unsigned char', not to 'int' [342]

diffstat:

 usr.bin/sdpquery/print.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 350b726e38d8 -r 8d8c1c005dd6 usr.bin/sdpquery/print.c
--- a/usr.bin/sdpquery/print.c  Fri Aug 27 17:38:57 2021 +0000
+++ b/usr.bin/sdpquery/print.c  Fri Aug 27 17:41:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.23 2019/10/24 18:18:00 kamil Exp $ */
+/*     $NetBSD: print.c,v 1.24 2021/08/27 17:41:39 rillig Exp $        */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: print.c,v 1.23 2019/10/24 18:18:00 kamil Exp $");
+__RCSID("$NetBSD: print.c,v 1.24 2021/08/27 17:41:39 rillig Exp $");
 
 #include <ctype.h>
 #include <iconv.h>
@@ -1059,7 +1059,8 @@
                        break;
 
                be16enc(lang, v);
-               if (!islower((int)lang[0]) || !islower((int)lang[1]))
+               if (!islower((unsigned char)lang[0]) ||
+                   !islower((unsigned char)lang[1]))
                        break;
 
                /*



Home | Main Index | Thread Index | Old Index