ncurses 5.9 - patch 20130216

+ modify test/testcurs.c to work with mouse for ncurses as it does for
  pdcurses.
+ modify test/knight.c to work with mouse for pdcurses as it does for
  ncurses.
+ modify internal recursion in wgetch() which handles cooked mode to
  check if the call to wgetnstr() returned an error.  This can happen
  when both nocbreak() and nodelay() are set, for instance (report by
  Nils Christopher Brause) (cf: 960418).
+ fixes for issues found by Coverity:
  + add a check for valid position in ClearToEOS()
  + fix in lib_twait.c when --enable-wgetch-events is used, pointer
    use after free.
  + improve a limit-check in make_hash.c
  + fix a memory leak in hashed_db.c
This commit is contained in:
Thomas E. Dickey 2013-02-17 00:03:45 +00:00
parent 1385381954
commit f486c68b1e
13 changed files with 112 additions and 32 deletions

18
NEWS
View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
-- $Id: NEWS,v 1.2021 2013/02/09 22:39:26 tom Exp $
-- $Id: NEWS,v 1.2023 2013/02/16 21:51:17 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
@ -45,6 +45,22 @@ See the AUTHORS file for the corresponding full names.
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
20130216
+ modify test/testcurs.c to work with mouse for ncurses as it does for
pdcurses.
+ modify test/knight.c to work with mouse for pdcurses as it does for
ncurses.
+ modify internal recursion in wgetch() which handles cooked mode to
check if the call to wgetnstr() returned an error. This can happen
when both nocbreak() and nodelay() are set, for instance (report by
Nils Christopher Brause) (cf: 960418).
+ fixes for issues found by Coverity:
+ add a check for valid position in ClearToEOS()
+ fix in lib_twait.c when --enable-wgetch-events is used, pointer
use after free.
+ improve a limit-check in make_hash.c
+ fix a memory leak in hashed_db.c
20130209
+ modify test/configure script to make it simpler to override names
of curses-related libraries, to help with linking with pdcurses in

View File

@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: dist.mk,v 1.913 2013/02/09 17:27:48 tom Exp $
# $Id: dist.mk,v 1.914 2013/02/16 16:48:32 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
@ -37,7 +37,7 @@ SHELL = /bin/sh
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 5
NCURSES_MINOR = 9
NCURSES_PATCH = 20130209
NCURSES_PATCH = 20130216
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
* Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -42,7 +42,7 @@
#include <curses.priv.h>
MODULE_ID("$Id: lib_getch.c,v 1.125 2012/08/04 17:11:37 tom Exp $")
MODULE_ID("$Id: lib_getch.c,v 1.126 2013/02/16 18:30:37 tom Exp $")
#include <fifo_defs.h>
@ -439,11 +439,11 @@ _nc_wgetch(WINDOW *win,
/* ungetch in reverse order */
#ifdef NCURSES_WGETCH_EVENTS
rc = recur_wgetnstr(win, buf);
if (rc != KEY_EVENT)
if (rc != KEY_EVENT && rc != ERR)
safe_ungetch(sp, '\n');
#else
(void) recur_wgetnstr(win, buf);
safe_ungetch(sp, '\n');
if (recur_wgetnstr(win, buf) != ERR)
safe_ungetch(sp, '\n');
#endif
for (bufp = buf + strlen(buf); bufp > buf; bufp--)
safe_ungetch(sp, bufp[-1]);

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2006-2008,2011 Free Software Foundation, Inc. *
* Copyright (c) 2006-2011,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -36,7 +36,7 @@
#if USE_HASHED_DB
MODULE_ID("$Id: hashed_db.c,v 1.15 2011/08/13 21:08:08 tom Exp $")
MODULE_ID("$Id: hashed_db.c,v 1.16 2013/02/16 21:50:03 tom Exp $")
#if HASHED_DB_API >= 2
static DBC *cursor;
@ -105,6 +105,8 @@ make_connection(DB * db, const char *path, bool modify)
if (p->path != 0) {
p->next = connections;
connections = p;
} else {
free(p);
}
}
}

View File

@ -44,7 +44,7 @@
#include <ctype.h>
MODULE_ID("$Id: make_hash.c,v 1.11 2013/01/26 22:00:11 tom Exp $")
MODULE_ID("$Id: make_hash.c,v 1.12 2013/02/16 21:27:50 tom Exp $")
/*
* _nc_make_hash_table()
@ -155,7 +155,7 @@ parse_columns(char *buffer)
int col = 0;
if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
if (list == 0 && (list = typeCalloc(char *, (MAX_COLUMNS + 1))) == 0)
return (0);
if (*buffer != '#') {

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
* Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -75,7 +75,7 @@
#endif
#undef CUR
MODULE_ID("$Id: lib_twait.c,v 1.65 2012/10/27 20:42:47 tom Exp $")
MODULE_ID("$Id: lib_twait.c,v 1.66 2013/02/16 20:52:07 tom Exp $")
static long
_nc_gettime(TimeType * t0, int first)
@ -289,10 +289,6 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
}
}
}
if (fds != fd_list)
free((char *) fds);
#endif
#elif defined(__BEOS__)
@ -505,5 +501,10 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
result |= TW_EVENT;
#endif
#ifdef NCURSES_WGETCH_EVENTS
if (fds != fd_list)
free((char *) fds);
#endif
return (result);
}

View File

@ -82,7 +82,7 @@
#include <ctype.h>
MODULE_ID("$Id: tty_update.c,v 1.275 2013/01/20 00:34:46 tom Exp $")
MODULE_ID("$Id: tty_update.c,v 1.276 2013/02/16 21:12:02 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@ -1118,6 +1118,11 @@ ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
row = SP_PARM->_cursrow;
col = SP_PARM->_curscol;
if (row < 0)
row = 0;
if (col < 0)
col = 0;
UpdateAttrs(SP_PARM, blank);
TPUTS_TRACE("clr_eos");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx

View File

@ -1,8 +1,8 @@
ncurses6 (5.9-20130209) unstable; urgency=low
ncurses6 (5.9-20130216) unstable; urgency=low
* latest weekly patch
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 09 Feb 2013 12:28:44 -0500
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 16 Feb 2013 11:48:20 -0500
ncurses6 (5.9-20120608) unstable; urgency=low

View File

@ -1,7 +1,7 @@
Summary: shared libraries for terminal handling
Name: ncurses6
Release: 5.9
Version: 20130209
Version: 20130216
License: X11
Group: Development/Libraries
Source: ncurses-%{release}-%{version}.tgz

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. *
* Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -34,7 +34,7 @@
* v2.0 featuring strict ANSI/POSIX conformance, November 1993.
* v2.1 with ncurses mouse support, September 1995
*
* $Id: bs.c,v 1.59 2012/12/16 00:20:49 tom Exp $
* $Id: bs.c,v 1.60 2013/02/16 19:54:37 tom Exp $
*/
#include <test.priv.h>
@ -956,7 +956,7 @@ cpufire(int x, int y)
bool hit, sunk;
ship_t *ss = NULL;
hit = board[PLAYER][x][y];
hit = (bool) board[PLAYER][x][y];
hits[COMPUTER][x][y] = (hit ? MARK_HIT : MARK_MISS);
MvPrintw(PROMPTLINE, 0,
"I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" :

View File

@ -33,7 +33,7 @@
* Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995. Mouse support
* added September 20th 1995.
*
* $Id: knight.c,v 1.35 2013/02/03 00:16:59 tom Exp $
* $Id: knight.c,v 1.36 2013/02/16 19:53:08 tom Exp $
*/
#include <test.priv.h>
@ -130,6 +130,9 @@ init_program(void)
#ifdef NCURSES_MOUSE_VERSION
(void) mousemask(BUTTON1_CLICKED, (mmask_t *) NULL);
#endif /* NCURSES_MOUSE_VERSION */
#if defined(PDCURSES)
mouse_set(BUTTON1_RELEASED);
#endif
oldch = minus;
}
@ -577,8 +580,9 @@ play(void)
nx = col + 1;
break;
#ifdef NCURSES_MOUSE_VERSION
#ifdef KEY_MOUSE
case KEY_MOUSE:
#ifdef NCURSES_MOUSE_VERSION
{
MEVENT myevent;
@ -595,6 +599,24 @@ play(void)
}
}
#endif /* NCURSES_MOUSE_VERSION */
#ifdef PDCURSES
{
int test_y, test_x;
request_mouse_pos();
test_y = MOUSE_Y_POS + 0;
test_x = MOUSE_X_POS + 1;
if (test_y >= CY(0) && test_y <= CY(BDEPTH)
&& test_x >= CX(0) && test_x <= CX(BWIDTH)) {
ny = CYINV(test_y);
nx = CXINV(test_x);
wmove(helpwin, 0, 0);
wrefresh(helpwin);
ungetch('\n');
}
break;
}
#endif /* PDCURSES */
#endif /* KEY_MOUSE */
case KEY_B2:
case '\n':

View File

@ -40,7 +40,7 @@ AUTHOR
Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
Thomas E. Dickey (beginning revision 1.27 in 1996).
$Id: ncurses.c,v 1.387 2013/01/13 00:40:17 tom Exp $
$Id: ncurses.c,v 1.388 2013/02/16 18:56:30 tom Exp $
***************************************************************************/
@ -6922,7 +6922,7 @@ main(int argc, char *argv[])
bkgdset(BLANK);
/* tests, in general, will want these modes */
use_colors = monochrome ? FALSE : has_colors();
use_colors = (bool) (monochrome ? FALSE : has_colors());
if (use_colors) {
start_color();

View File

@ -6,7 +6,7 @@
* wrs(5/28/93) -- modified to be consistent (perform identically) with either
* PDCurses or under Unix System V, R4
*
* $Id: testcurs.c,v 1.46 2012/11/24 19:38:20 tom Exp $
* $Id: testcurs.c,v 1.47 2013/02/16 20:29:04 tom Exp $
*/
#include <test.priv.h>
@ -341,6 +341,9 @@ inputTest(WINDOW *win)
typeahead(-1);
#endif
#ifdef NCURSES_MOUSE_VERSION
mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
#endif
#if defined(PDCURSES)
mouse_set(ALL_MOUSE_EVENTS);
#endif
@ -355,8 +358,38 @@ inputTest(WINDOW *win)
wprintw(win, "Key Pressed: %c", c);
else
wprintw(win, "Key Pressed: %s", unctrl(UChar(c)));
#if defined(PDCURSES)
#ifdef KEY_MOUSE
#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, 037))
#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED))
#define ButtonDouble(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED))
#define ButtonTriple(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED))
#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED))
if (c == KEY_MOUSE) {
MEVENT event;
int button = 0;
getmouse(&event);
if (ButtonChanged(1))
button = 1;
else if (ButtonChanged(2))
button = 2;
else if (ButtonChanged(3))
button = 3;
else
button = 0;
wmove(win, 4, 18);
wprintw(win, "Button %d: ", button);
if (ButtonPressed(button))
wprintw(win, "pressed: ");
else if (ButtonDouble(button))
wprintw(win, "double: ");
else if (ButtonTriple(button))
wprintw(win, "triple: ");
else
wprintw(win, "released: ");
wprintw(win, " Position: Y: %d X: %d", event.y, event.x);
#if defined(NCURSES_MOUSE_VERSION)
#elif defined(PDCURSES)
int button = 0;
request_mouse_pos();
if (BUTTON_CHANGED(1))
@ -378,8 +411,9 @@ inputTest(WINDOW *win)
else
wprintw(win, "released: ");
wprintw(win, " Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
#endif /* PDCURSES */
}
#endif
#endif /* KEY_MOUSE */
wrefresh(win);
if (c == ' ')
break;