Module Name:    src
Committed By:   rillig
Date:           Thu Oct  7 18:19:07 UTC 2021

Modified Files:
        src/usr.bin/indent: indent.c

Log Message:
indent: prevent division by zero


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 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.108 src/usr.bin/indent/indent.c:1.109
--- src/usr.bin/indent/indent.c:1.108	Tue Oct  5 18:50:42 2021
+++ src/usr.bin/indent/indent.c	Thu Oct  7 18:19:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.108 2021/10/05 18:50:42 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.109 2021/10/07 18:19:07 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.108 2021/10/05 18:50:42 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.109 2021/10/07 18:19:07 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -491,6 +491,10 @@ main_parse_command_line(int argc, char *
 	    : opt.comment_column;
     if (opt.continuation_indent == 0)
 	opt.continuation_indent = opt.indent_size;
+    if (!(1 <= opt.tabsize && opt.tabsize <= 80))
+	errx(EXIT_FAILURE, "invalid tabsize %d", opt.tabsize);
+    if (!(1 <= opt.indent_size && opt.indent_size <= 80))
+	errx(EXIT_FAILURE, "invalid indentation %d", opt.indent_size);
 }
 
 static void

Reply via email to