Module Name:    src
Committed By:   maxv
Date:           Wed Aug 26 16:36:32 UTC 2020

Modified Files:
        src/sys/kern: tty.c

Log Message:
Add a check to prevent shift by -1. Not really important in this case,
but to appease KUBSAN.

Reported-by: syzbot+4026e8201b6b484b8...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 src/sys/kern/tty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/tty.c
diff -u src/sys/kern/tty.c:1.288 src/sys/kern/tty.c:1.289
--- src/sys/kern/tty.c:1.288	Mon Jun 22 16:29:24 2020
+++ src/sys/kern/tty.c	Wed Aug 26 16:36:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.288 2020/06/22 16:29:24 maxv Exp $	*/
+/*	$NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.288 2020/06/22 16:29:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -226,6 +226,9 @@ int tty_qsize = TTY_MINQSIZE;
 static int
 tty_get_qsize(int *qsize, int newsize)
 {
+	if (newsize == 0)
+		return EINVAL;
+
 	newsize = 1 << ilog2(newsize);	/* Make it a power of two */
 
 	if (newsize < TTY_MINQSIZE || newsize > TTY_MAXQSIZE)

Reply via email to