Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/stat stat: fix undefined behavior when calling ctype...
details: https://anonhg.NetBSD.org/src/rev/4cf28198d814
branches: trunk
changeset: 1023149:4cf28198d814
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Aug 27 18:11:07 2021 +0000
description:
stat: fix undefined behavior when calling ctype functions
lint says: warning: argument to 'function from <ctype.h>' must be cast
to 'unsigned char', not to 'unsigned int' [342]
diffstat:
usr.bin/stat/stat.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (39 lines):
diff -r 96314fa538da -r 4cf28198d814 usr.bin/stat/stat.c
--- a/usr.bin/stat/stat.c Fri Aug 27 18:09:30 2021 +0000
+++ b/usr.bin/stat/stat.c Fri Aug 27 18:11:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stat.c,v 1.46 2020/09/07 00:46:38 mrg Exp $ */
+/* $NetBSD: stat.c,v 1.47 2021/08/27 18:11:07 rillig Exp $ */
/*
* Copyright (c) 2002-2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: stat.c,v 1.46 2020/09/07 00:46:38 mrg Exp $");
+__RCSID("$NetBSD: stat.c,v 1.47 2021/08/27 18:11:07 rillig Exp $");
#endif
#if ! HAVE_NBTOOL_CONFIG_H
@@ -469,9 +469,9 @@
} while (1/*CONSTCOND*/);
size = -1;
- if (isdigit((unsigned)*statfmt)) {
+ if (isdigit((unsigned char)*statfmt)) {
size = 0;
- while (isdigit((unsigned)*statfmt)) {
+ while (isdigit((unsigned char)*statfmt)) {
size = (size * 10) + (*statfmt - '0');
statfmt++;
if (size < 0)
@@ -484,7 +484,7 @@
statfmt++;
prec = 0;
- while (isdigit((unsigned)*statfmt)) {
+ while (isdigit((unsigned char)*statfmt)) {
prec = (prec * 10) + (*statfmt - '0');
statfmt++;
if (prec < 0)
Home |
Main Index |
Thread Index |
Old Index