Module Name: src Committed By: rillig Date: Sun Oct 18 19:11:35 UTC 2020
Modified Files: src/usr.bin/make: Makefile parse.c Log Message: make(1): fix GCC warning about small buffer for cohort_num Since unmade_cohorts is a signed number (the code contains an underflow check), the result of the '%' operator could be negative and result in "#-999999", which would overflow the buffer, truncating the last digit. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/Makefile cvs rdiff -u -r1.386 -r1.387 src/usr.bin/make/parse.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/make/Makefile diff -u src/usr.bin/make/Makefile:1.103 src/usr.bin/make/Makefile:1.104 --- src/usr.bin/make/Makefile:1.103 Mon Oct 5 22:15:45 2020 +++ src/usr.bin/make/Makefile Sun Oct 18 19:11:35 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.103 2020/10/05 22:15:45 rillig Exp $ +# $NetBSD: Makefile,v 1.104 2020/10/18 19:11:35 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -65,7 +65,6 @@ COPTS.arch.c+= -Wno-error=format-truncat COPTS.dir.c+= -Wno-error=format-truncation COPTS.main.c+= -Wno-error=format-truncation COPTS.meta.c+= -Wno-error=format-truncation -COPTS.parse.c+= -Wno-error=format-truncation .endif # Whether to compile with GCC 9 from pkgsrc, during development. @@ -88,7 +87,6 @@ COPTS.arch.c+= -Wno-error=format-truncat COPTS.dir.c+= -Wno-error=format-truncation COPTS.main.c+= -Wno-error=format-truncation COPTS.meta.c+= -Wno-error=format-truncation -COPTS.parse.c+= -Wno-error=format-truncation .endif USE_META?= yes @@ -160,7 +158,6 @@ COPTS.arch.c+= ${GCC_NO_FORMAT_TRUNCATIO COPTS.dir.c+= ${GCC_NO_FORMAT_TRUNCATION} COPTS.main.c+= ${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION} COPTS.meta.c+= ${GCC_NO_FORMAT_TRUNCATION} -COPTS.parse.c+= ${GCC_NO_FORMAT_TRUNCATION} COPTS+= -Wdeclaration-after-statement Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.386 src/usr.bin/make/parse.c:1.387 --- src/usr.bin/make/parse.c:1.386 Sun Oct 18 17:19:54 2020 +++ src/usr.bin/make/parse.c Sun Oct 18 19:11:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.386 2020/10/18 17:19:54 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.387 2020/10/18 19:11:35 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.386 2020/10/18 17:19:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.387 2020/10/18 19:11:35 rillig Exp $"); /* types and constants */ @@ -834,7 +834,7 @@ TryApplyDependencyOperator(GNode *gn, GN cohort->centurion = gn; gn->unmade_cohorts++; snprintf(cohort->cohort_num, sizeof cohort->cohort_num, "#%d", - gn->unmade_cohorts % 1000000); + (unsigned int)gn->unmade_cohorts % 1000000); } else { /* * We don't want to nuke any previous flags (whatever they were) so we