Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses newwin - fix crash with negative ncols.



details:   https://anonhg.NetBSD.org/src/rev/e648c70fe825
branches:  trunk
changeset: 973826:e648c70fe825
user:      uwe <uwe%NetBSD.org@localhost>
date:      Tue Jul 14 04:39:39 2020 +0000

description:
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

diffstat:

 lib/libcurses/newwin.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 4ae000cb84fb -r e648c70fe825 lib/libcurses/newwin.c
--- a/lib/libcurses/newwin.c    Tue Jul 14 01:05:06 2020 +0000
+++ b/lib/libcurses/newwin.c    Tue Jul 14 04:39:39 2020 +0000
@@ -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 @@
 #endif /* HAVE_WCHAR */
                }
                lp->hash = __hash((char *)(void *)lp->line,
-                                 (size_t)(ncols * __LDATASIZE));
+                                 (size_t)(maxx * __LDATASIZE));
        }
        return (win);
 }



Home | Main Index | Thread Index | Old Index