Module Name: src
Committed By: rillig
Date: Fri Oct 29 18:50:52 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c
Log Message:
indent: mark obviously broken code
To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/indent/indent.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/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.171 src/usr.bin/indent/indent.c:1.172
--- src/usr.bin/indent/indent.c:1.171 Fri Oct 29 17:50:37 2021
+++ src/usr.bin/indent/indent.c Fri Oct 29 18:50:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.171 2021/10/29 17:50:37 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.172 2021/10/29 18:50:52 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.171 2021/10/29 17:50:37 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.172 2021/10/29 18:50:52 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -188,6 +188,12 @@ search_stmt_comment(bool *comment_buffer
* process_comment() will use that to calculate original indentation
* of a boxed comment.
*/
+ /*
+ * FIXME: This '4' needs an explanation. For example, in the snippet
+ * 'if(expr)/''*comment', the 'r)' of the code is not copied. If there
+ * is an additional line break before the ')', memcpy tries to copy
+ * (size_t)-1 bytes.
+ */
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] = ' ';