Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): fix undefined behavior in ParseEOF
details: https://anonhg.NetBSD.org/src/rev/5dbdbe8932b6
branches: trunk
changeset: 978899:5dbdbe8932b6
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 06 18:37:04 2020 +0000
description:
make(1): fix undefined behavior in ParseEOF
Adding a number to a null pointer should have been caught by any
Undefined Behavior Sanitizer, but apparently neither GCC nor Clang do
this.
diffstat:
usr.bin/make/parse.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r 59ac523991c8 -r 5dbdbe8932b6 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Dec 06 18:13:17 2020 +0000
+++ b/usr.bin/make/parse.c Sun Dec 06 18:37:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.469 2020/12/05 19:46:04 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.470 2020/12/06 18:37:04 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.469 2020/12/05 19:46:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.470 2020/12/06 18:37:04 rillig Exp $");
/* types and constants */
@@ -2623,7 +2623,7 @@
ptr = curFile->nextbuf(curFile->nextbuf_arg, &len);
curFile->buf_ptr = ptr;
curFile->buf_freeIt = ptr;
- curFile->buf_end = ptr + len; /* XXX: undefined behavior if ptr == NULL */
+ curFile->buf_end = ptr == NULL ? NULL : ptr + len;
curFile->lineno = curFile->first_lineno;
if (ptr != NULL)
return TRUE; /* Iterate again */
Home |
Main Index |
Thread Index |
Old Index