Module Name:    src
Committed By:   uwe
Date:           Tue Jul 14 04:39:39 UTC 2020

Modified Files:
        src/lib/libcurses: newwin.c

Log Message:
newwin - fix crash with negative ncols.

When support for negative nrows/ncols was added, one s/ncols/maxx/ was
missed so we ended up passing negative (i.e. huge unsigned) length
when hashing the line contents.

Reported by Naman Jain in PR lib/55484


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/lib/libcurses/newwin.c

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

Modified files:

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.57 src/lib/libcurses/newwin.c:1.58
--- src/lib/libcurses/newwin.c:1.57	Sun Jun  9 07:40:14 2019
+++ src/lib/libcurses/newwin.c	Tue Jul 14 04:39:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.57 2019/06/09 07:40:14 blymn Exp $	*/
+/*	$NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c	8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.57 2019/06/09 07:40:14 blymn Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $");
 #endif
 #endif				/* not lint */
 
@@ -174,7 +174,7 @@ __newwin(SCREEN *screen, int nlines, int
 #endif /* HAVE_WCHAR */
 		}
 		lp->hash = __hash((char *)(void *)lp->line,
-				  (size_t)(ncols * __LDATASIZE));
+				  (size_t)(maxx * __LDATASIZE));
 	}
 	return (win);
 }

Reply via email to