Module Name: src Committed By: rillig Date: Fri Aug 27 18:11:07 UTC 2021
Modified Files: src/usr.bin/stat: stat.c Log Message: 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] To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/usr.bin/stat/stat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/stat/stat.c diff -u src/usr.bin/stat/stat.c:1.46 src/usr.bin/stat/stat.c:1.47 --- src/usr.bin/stat/stat.c:1.46 Mon Sep 7 00:46:38 2020 +++ src/usr.bin/stat/stat.c Fri Aug 27 18:11:07 2021 @@ -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 @@ output(const struct stat *st, const char } 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 @@ output(const struct stat *st, const char statfmt++; prec = 0; - while (isdigit((unsigned)*statfmt)) { + while (isdigit((unsigned char)*statfmt)) { prec = (prec * 10) + (*statfmt - '0'); statfmt++; if (prec < 0)