From 20db1fb41ec91cd8a1f528e770362092c5403378 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 24 Apr 2022 00:17:21 +0000 Subject: [PATCH] ncurses 6.3 - patch 20220423 + in-progress work on invalid_merge(), disable it (cf: 20220402). + fix memory leak in _nc_tic_dir() when called from _nc_set_writedir(). + fix memory leak in tic when "-c" option is used. --- NEWS | 7 ++++++- VERSION | 2 +- dist.mk | 4 ++-- ncurses/tinfo/comp_parse.c | 12 ++++++++++-- ncurses/tinfo/db_iterator.c | 17 +++++++++++++---- ncurses/tinfo/write_entry.c | 4 ++-- package/debian-mingw/changelog | 4 ++-- package/debian-mingw64/changelog | 4 ++-- package/debian/changelog | 4 ++-- package/mingw-ncurses.nsi | 4 ++-- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- package/ncursest.spec | 2 +- progs/tic.c | 6 +++--- 14 files changed, 48 insertions(+), 26 deletions(-) diff --git a/NEWS b/NEWS index 4e47245a..0c1a85a3 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +26,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.3796 2022/04/16 23:31:41 tom Exp $ +-- $Id: NEWS,v 1.3798 2022/04/23 23:26:44 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,11 @@ 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. +20220423 + + in-progress work on invalid_merge(), disable it (cf: 20220402). + + fix memory leak in _nc_tic_dir() when called from _nc_set_writedir(). + + fix memory leak in tic when "-c" option is used. + 20220416 + add a limit-check to guard against corrupt terminfo data (report/testcase by NCNIPC of China). diff --git a/VERSION b/VERSION index 687f5313..d25d1348 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.3 20220416 +5:0:10 6.3 20220423 diff --git a/dist.mk b/dist.mk index bc97ee6a..28d52954 100644 --- a/dist.mk +++ b/dist.mk @@ -26,7 +26,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1475 2022/04/16 12:59:30 tom Exp $ +# $Id: dist.mk,v 1.1476 2022/04/23 12:44:18 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -38,7 +38,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 3 -NCURSES_PATCH = 20220416 +NCURSES_PATCH = 20220423 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c index 7d02a90c..4951377f 100644 --- a/ncurses/tinfo/comp_parse.c +++ b/ncurses/tinfo/comp_parse.c @@ -48,7 +48,7 @@ #include -MODULE_ID("$Id: comp_parse.c,v 1.114 2022/04/02 22:13:54 tom Exp $") +MODULE_ID("$Id: comp_parse.c,v 1.116 2022/04/23 23:23:38 tom Exp $") static void sanity_check2(TERMTYPE2 *, bool); NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2; @@ -266,7 +266,7 @@ _nc_read_entry_source(FILE *fp, char *buf, _nc_suppress_warnings = oldsuppress; } -#if NCURSES_XNAMES +#if 0 && NCURSES_XNAMES static unsigned find_capname(TERMTYPE2 *p, const char *name) { @@ -631,6 +631,14 @@ _nc_resolve_uses2(bool fullresolve, bool literal) _nc_check_termtype2(&qp->tterm, literal); + /* + * Checking calls tparm, which can allocate memory. Fix leaks. + */ +#define TPS(name) fake_tm.tparm_state.name + FreeAndNull(TPS(out_buff)); + FreeAndNull(TPS(fmt_buff)); +#undef TPS + _nc_set_screen(save_SP); set_curterm(save_tm); } else { diff --git a/ncurses/tinfo/db_iterator.c b/ncurses/tinfo/db_iterator.c index f0726682..e69e0f34 100644 --- a/ncurses/tinfo/db_iterator.c +++ b/ncurses/tinfo/db_iterator.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2018-2020,2022 Thomas E. Dickey * * Copyright 2006-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -44,7 +44,7 @@ #include #endif -MODULE_ID("$Id: db_iterator.c,v 1.48 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: db_iterator.c,v 1.49 2022/04/23 20:03:15 tom Exp $") #define HaveTicDirectory _nc_globals.have_tic_directory #define KeepTicDirectory _nc_globals.keep_tic_directory @@ -202,6 +202,13 @@ free_cache(void) FreeAndNull(my_list); } +static void +update_tic_dir(const char *update) +{ + free((char *) TicDirectory); + TicDirectory = update; +} + /* * Record the "official" location of the terminfo directory, according to * the place where we're writing to, or the normal default, if not. @@ -211,8 +218,9 @@ _nc_tic_dir(const char *path) { T(("_nc_tic_dir %s", NonNull(path))); if (!KeepTicDirectory) { - if (path != 0) { - TicDirectory = path; + if (path != NULL) { + if (path != TicDirectory) + update_tic_dir(strdup(path)); HaveTicDirectory = TRUE; } else if (HaveTicDirectory == 0) { if (use_terminfo_vars()) { @@ -444,5 +452,6 @@ _nc_db_iterator_leaks(void) FreeIfNeeded(my_vars[which].value); my_vars[which].value = 0; } + update_tic_dir(NULL); } #endif diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c index 05fea946..e1baf9e2 100644 --- a/ncurses/tinfo/write_entry.c +++ b/ncurses/tinfo/write_entry.c @@ -51,7 +51,7 @@ #define TRACE_NUM(n) /* nothing */ #endif -MODULE_ID("$Id: write_entry.c,v 1.119 2022/02/26 20:59:58 tom Exp $") +MODULE_ID("$Id: write_entry.c,v 1.120 2022/04/23 19:59:10 tom Exp $") static int total_written; static int total_parts; @@ -248,7 +248,7 @@ _nc_set_writedir(const char *dir) || getcwd(actual, sizeof(actual)) == 0) _nc_err_abort("%s: not a directory", destination); #endif - _nc_keep_tic_dir(strdup(actual)); + _nc_keep_tic_dir(actual); } /* diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index 03bde704..2a2f2312 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.3+20220416) unstable; urgency=low +ncurses6 (6.3+20220423) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 16 Apr 2022 08:59:30 -0400 + -- Thomas E. Dickey Sat, 23 Apr 2022 08:44:18 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index 03bde704..2a2f2312 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.3+20220416) unstable; urgency=low +ncurses6 (6.3+20220423) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 16 Apr 2022 08:59:30 -0400 + -- Thomas E. Dickey Sat, 23 Apr 2022 08:44:18 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 3ac34a1e..8847c82c 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.3+20220416) unstable; urgency=low +ncurses6 (6.3+20220423) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 16 Apr 2022 08:59:30 -0400 + -- Thomas E. Dickey Sat, 23 Apr 2022 08:44:18 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 6dd8ba23..b92882c3 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.515 2022/04/16 12:59:30 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.516 2022/04/23 12:44:18 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "3" !define VERSION_YYYY "2022" -!define VERSION_MMDD "0416" +!define VERSION_MMDD "0423" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 1028ce58..9537593d 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 6.3 -Release: 20220416 +Release: 20220423 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index 43c39805..e9e42a11 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.3 -Release: 20220416 +Release: 20220423 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncursest.spec b/package/ncursest.spec index 8a57c8c8..d5529f16 100644 --- a/package/ncursest.spec +++ b/package/ncursest.spec @@ -1,7 +1,7 @@ Summary: Curses library with POSIX thread support. Name: ncursest6 Version: 6.3 -Release: 20220416 +Release: 20220423 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/progs/tic.c b/progs/tic.c index c8736c30..152010d2 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -49,7 +49,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.310 2022/04/09 22:17:45 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.311 2022/04/23 19:47:57 tom Exp $") #define STDIN_NAME "" @@ -644,7 +644,7 @@ show_databases(const char *outdir) const char *tried = 0; if (outdir == NULL) { - outdir = _nc_tic_dir(0); + outdir = _nc_tic_dir(NULL); } if ((result = valid_db_path(outdir)) != 0) { printf("%s\n", result); @@ -1081,7 +1081,7 @@ main(int argc, char *argv[]) if (total != 0) fprintf(log_fp, "%d entries written to %s\n", total, - _nc_tic_dir((char *) 0)); + _nc_tic_dir(NULL)); else fprintf(log_fp, "No entries written\n"); } -- 2.44.0