From: Thomas E. Dickey Date: Sun, 6 Dec 2009 01:32:45 +0000 (+0000) Subject: ncurses 5.7 - patch 20091205 X-Git-Tag: v5.8~59 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=cb9a015f6669e86dd5db0fcdf1a6d74c7ea5df55 ncurses 5.7 - patch 20091205 + correct layout of working window used to extract data in wide-character configured by set_field_buffer (patch by Rafael Garrido Fernandez) + improve some limit-checks related to filename length in reading and writing terminfo entries. + ensure that filename is always filled in when attempting to read a terminfo entry, so that infocmp can report the filename (patch by Nicholas Marriott). --- diff --git a/NEWS b/NEWS index ed5026c3..7bcb7b7e 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1468 2009/11/28 22:51:06 tom Exp $ +-- $Id: NEWS,v 1.1470 2009/12/05 22:07:39 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,16 @@ 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. +20091205 + + correct layout of working window used to extract data in + wide-character configured by set_field_buffer (patch by Rafael + Garrido Fernandez) + + improve some limit-checks related to filename length in reading and + writing terminfo entries. + + ensure that filename is always filled in when attempting to read + a terminfo entry, so that infocmp can report the filename (patch + by Nicholas Marriott). + 20091128 + modify mk-1st.awk to allow tinfo library to be built when term-driver is enabled. diff --git a/dist.mk b/dist.mk index 91779a9d..4d8c11b4 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.733 2009/11/28 17:54:26 tom Exp $ +# $Id: dist.mk,v 1.734 2009/12/05 18:20:30 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 = 7 -NCURSES_PATCH = 20091128 +NCURSES_PATCH = 20091205 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/form/frm_driver.c b/form/frm_driver.c index e919163e..67e4c39f 100644 --- a/form/frm_driver.c +++ b/form/frm_driver.c @@ -32,7 +32,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_driver.c,v 1.94 2009/11/07 19:54:03 tom Exp $") +MODULE_ID("$Id: frm_driver.c,v 1.95 2009/12/05 21:45:58 Rafael.Garrido.Fernandez Exp $") /*---------------------------------------------------------------------------- This is the core module of the form library. It contains the majority @@ -4430,11 +4430,11 @@ set_field_buffer(FIELD *field, int buffer, const char *value) * and other special cases that we really do not want to handle here. */ #if NCURSES_EXT_FUNCS - if (wresize(field->working, field->drows, field->dcols) == ERR) + if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR) #endif { delwin(field->working); - field->working = newpad(field->drows, field->dcols); + field->working = newpad(1, Buffer_Length(field) + 1); } len = Buffer_Length(field); wclear(field->working); @@ -4448,7 +4448,7 @@ set_field_buffer(FIELD *field, int buffer, const char *value) { for (i = 0; i < (unsigned)field->drows; ++i) { - mvwin_wchnstr(field->working, i, 0, + mvwin_wchnstr(field->working, 0, i * field->dcols, widevalue + (i * field->dcols), field->dcols); } diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 69f9e18c..dbc5e29c 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ /* - * $Id: curses.priv.h,v 1.444 2009/11/28 22:43:12 tom Exp $ + * $Id: curses.priv.h,v 1.445 2009/12/05 21:20:51 tom Exp $ * * curses.priv.h * @@ -686,8 +686,10 @@ typedef struct { */ #if MIXEDCASE_FILENAMES #define LEAF_FMT "%c" +#define LEAF_LEN 1 #else #define LEAF_FMT "%02x" +#define LEAF_LEN 2 #endif /* diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c index b4ea61ca..b34ed8dd 100644 --- a/ncurses/tinfo/read_entry.c +++ b/ncurses/tinfo/read_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 #include -MODULE_ID("$Id: read_entry.c,v 1.102 2008/08/03 19:33:04 tom Exp $") +MODULE_ID("$Id: read_entry.c,v 1.105 2009/12/06 01:22:26 tom Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -314,7 +314,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit) if (need) { if (ext_str_count >= (MAX_ENTRY_SIZE * 2)) - return (TGETENT_NO); + return (TGETENT_NO); if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0) return (TGETENT_NO); TR(TRACE_DATABASE, @@ -404,26 +404,22 @@ _nc_read_tic_entry(char *filename, /* * If we are looking in a directory, assume the entry is a file under that, * according to the normal rules. - * - * FIXME - add caseless-filename fixup. */ - if (_nc_is_dir_path(path)) { - unsigned need = 4 + strlen(path) + strlen(name); + unsigned need = LEAF_LEN + 3 + strlen(path) + strlen(name); + if (need <= limit) + (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name); - if (need <= limit) { - (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name); - result = _nc_read_file_entry(filename, tp); - } - } + if (_nc_is_dir_path(path)) + result = _nc_read_file_entry(filename, tp); #if USE_HASHED_DB else { static const char suffix[] = DBM_SUFFIX; DB *capdbp; unsigned lens = sizeof(suffix) - 1; unsigned size = strlen(path); - unsigned need = lens + size; + unsigned test = lens + size; - if (need <= limit) { + if (test < limit) { if (size >= lens && !strcmp(path + size - lens, suffix)) (void) strcpy(filename, path); @@ -515,6 +511,7 @@ _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp) { int code = TGETENT_NO; + sprintf(filename, "%.*s", PATH_MAX - 1, name); if (strlen(name) == 0 || strcmp(name, ".") == 0 || strcmp(name, "..") == 0 diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c index 057b3c22..2552eea5 100644 --- a/ncurses/tinfo/write_entry.c +++ b/ncurses/tinfo/write_entry.c @@ -54,7 +54,7 @@ #define TRACE_OUT(p) /*nothing */ #endif -MODULE_ID("$Id: write_entry.c,v 1.74 2009/09/19 20:30:48 Daniel.Jacobowitz Exp $") +MODULE_ID("$Id: write_entry.c,v 1.75 2009/12/05 21:25:01 tom Exp $") static int total_written; @@ -137,10 +137,12 @@ make_db_path(char *dst, const char *src, unsigned limit) if (_nc_is_dir_path(dst)) { rc = -1; } else { + static const char suffix[] = DBM_SUFFIX; unsigned have = strlen(dst); - if (have > 3 && strcmp(dst + have - 3, DBM_SUFFIX)) { - if (have + 3 <= limit) - strcat(dst, DBM_SUFFIX); + unsigned need = strlen(suffix); + if (have > need && strcmp(dst + have - need, suffix)) { + if (have + need <= limit) + strcat(dst, suffix); else rc = -1; } @@ -362,7 +364,7 @@ _nc_write_entry(TERMTYPE *const tp) start_time = 0; } - if (strlen(first_name) >= sizeof(filename) - 3) + if (strlen(first_name) >= sizeof(filename) - (2 + LEAF_LEN)) _nc_warning("terminal name too long."); sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name); @@ -396,7 +398,7 @@ _nc_write_entry(TERMTYPE *const tp) if (*other_names != '\0') *(other_names++) = '\0'; - if (strlen(ptr) > sizeof(linkname) - 3) { + if (strlen(ptr) > sizeof(linkname) - (2 + LEAF_LEN)) { _nc_warning("terminal alias %s too long.", ptr); continue; } diff --git a/progs/infocmp.c b/progs/infocmp.c index 84989ffc..0c36c2de 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 -MODULE_ID("$Id: infocmp.c,v 1.103 2008/08/16 22:04:56 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.104 2009/12/05 21:10:31 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -1255,6 +1255,15 @@ terminal_env(void) * ***************************************************************************/ +#if NO_LEAKS +#define MAIN_LEAKS() \ + free(myargv); \ + free(tfile); \ + free(tname) +#else +#define MAIN_LEAKS() /* nothing */ +#endif + int main(int argc, char *argv[]) { @@ -1514,6 +1523,7 @@ main(int argc, char *argv[]) #else (void) fprintf(stderr, "%s: terminfo files not supported\n", _nc_progname); + MAIN_LEAKS(); ExitProgram(EXIT_FAILURE); #endif } else { @@ -1534,6 +1544,7 @@ main(int argc, char *argv[]) "%s: couldn't open terminfo file %s.\n", _nc_progname, tfile[termcount]); + MAIN_LEAKS(); ExitProgram(EXIT_FAILURE); } repair_acsc(&entries[termcount].tterm); @@ -1642,11 +1653,7 @@ main(int argc, char *argv[]) else file_comparison(argc - optind, argv + optind); -#if NO_LEAKS - free(myargv); - free(tfile); - free(tname); -#endif + MAIN_LEAKS(); ExitProgram(EXIT_SUCCESS); }