Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: replace segmentation fault with asser...
details: https://anonhg.NetBSD.org/src/rev/8029eb7bd9c5
branches: trunk
changeset: 990525:8029eb7bd9c5
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Oct 29 20:05:58 2021 +0000
description:
indent: replace segmentation fault with assertion
diffstat:
tests/usr.bin/indent/t_errors.sh | 4 ++--
usr.bin/indent/indent.c | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diffs (53 lines):
diff -r c1e25bab706e -r 8029eb7bd9c5 tests/usr.bin/indent/t_errors.sh
--- a/tests/usr.bin/indent/t_errors.sh Fri Oct 29 19:52:59 2021 +0000
+++ b/tests/usr.bin/indent/t_errors.sh Fri Oct 29 20:05:58 2021 +0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: t_errors.sh,v 1.12 2021/10/29 19:39:32 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.13 2021/10/29 20:05:58 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -413,7 +413,7 @@
{
printf '{if(expr\n)/*c*/;}\n' > code.c
- atf_check -s 'signal' \
+ atf_check -s 'signal' -o 'ignore' -e 'match:assert' \
"$indent" code.c -st
}
diff -r c1e25bab706e -r 8029eb7bd9c5 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Fri Oct 29 19:52:59 2021 +0000
+++ b/usr.bin/indent/indent.c Fri Oct 29 20:05:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.175 2021/10/29 19:31:24 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.176 2021/10/29 20:05:58 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.175 2021/10/29 19:31:24 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.176 2021/10/29 20:05:58 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -53,6 +53,7 @@
#include <sys/capsicum.h>
#include <capsicum_helpers.h>
#endif
+#include <assert.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -194,6 +195,7 @@
* is an additional line break before the ')', memcpy tries to copy
* (size_t)-1 bytes.
*/
+ assert((size_t)(inp.s - inp.buf) >= 4);
memcpy(sc_buf, inp.buf, (size_t)(inp.s - inp.buf) - 4);
save_com = sc_buf + (inp.s - inp.buf - 4);
save_com[0] = save_com[1] = ' ';
Home |
Main Index |
Thread Index |
Old Index