]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.7 - patch 20091205
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 6 Dec 2009 01:32:45 +0000 (01:32 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 6 Dec 2009 01:32:45 +0000 (01:32 +0000)
+ 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).

NEWS
dist.mk
form/frm_driver.c
ncurses/curses.priv.h
ncurses/tinfo/read_entry.c
ncurses/tinfo/write_entry.c
progs/infocmp.c

diff --git a/NEWS b/NEWS
index ed5026c3246e35bcac7efef74dad7a43d5ede72e..7bcb7b7eaeb4d950fea998576f476417c536c70c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- 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
 -------------------------------------------------------------------------------
 
 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.
 
 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.
 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 91779a9da0b16cb556fdb3f11af963f5e1eb6564..4d8c11b4e8e2c29292f19ac9aaa1fca362126493 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # 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
 # 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
 # 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)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index e919163edecb9a04e127893d77be961d6abeb467..67e4c39f398a0e4334d8f53591f9ec84c757bbef 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "form.priv.h"
 
 
 #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
 
 /*----------------------------------------------------------------------------
   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
    * 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);
 #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);
     }
   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)
        {
     {
       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);
        }
                        widevalue + (i * field->dcols),
                        field->dcols);
        }
index 69f9e18c2ee978e0be69a295f4d3b019a45e29d2..dbc5e29cec10ac6ec6e2bf4700150dd484c377a8 100644 (file)
@@ -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
  *
  *
  *     curses.priv.h
  *
@@ -686,8 +686,10 @@ typedef struct {
  */
 #if MIXEDCASE_FILENAMES
 #define LEAF_FMT "%c"
  */
 #if MIXEDCASE_FILENAMES
 #define LEAF_FMT "%c"
+#define LEAF_LEN 1
 #else
 #define LEAF_FMT "%02x"
 #else
 #define LEAF_FMT "%02x"
+#define LEAF_LEN 2
 #endif
 
 /*
 #endif
 
 /*
index b4ea61ca194ef59b1486267faab230fc53784136..b34ed8ddc12822eb9adb09eb03d7a7da89a7343e 100644 (file)
@@ -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            *
  *                                                                          *
  * 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 <tic.h>
 #include <term_entry.h>
 
 #include <tic.h>
 #include <term_entry.h>
 
-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))
 
 
 #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))
 
        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,
            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.
     /*
      * 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);
 #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);
            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;
 
 {
     int code = TGETENT_NO;
 
+    sprintf(filename, "%.*s", PATH_MAX - 1, name);
     if (strlen(name) == 0
        || strcmp(name, ".") == 0
        || strcmp(name, "..") == 0
     if (strlen(name) == 0
        || strcmp(name, ".") == 0
        || strcmp(name, "..") == 0
index 057b3c22a44782dd2593bcad485da579a57c4667..2552eea56df9bcfc5f93de186ff21887c2debf3e 100644 (file)
@@ -54,7 +54,7 @@
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
 #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;
 
 
 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 {
        if (_nc_is_dir_path(dst)) {
            rc = -1;
        } else {
+           static const char suffix[] = DBM_SUFFIX;
            unsigned have = strlen(dst);
            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;
            }
                else
                    rc = -1;
            }
@@ -362,7 +364,7 @@ _nc_write_entry(TERMTYPE *const tp)
        start_time = 0;
     }
 
        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);
        _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 (*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;
        }
            _nc_warning("terminal alias %s too long.", ptr);
            continue;
        }
index 84989ffc63d44cbff7e321feb7ba00d623f2b401..0c36c2de03a74c4d67017795a5c1355fc81da4fb 100644 (file)
@@ -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            *
  *                                                                          *
  * 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 <dump_entry.h>
 
 
 #include <dump_entry.h>
 
-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 "}"
 
 #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[])
 {
 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);
 #else
                (void) fprintf(stderr, "%s: terminfo files not supported\n",
                               _nc_progname);
+               MAIN_LEAKS();
                ExitProgram(EXIT_FAILURE);
 #endif
            } else {
                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]);
                               "%s: couldn't open terminfo file %s.\n",
                               _nc_progname,
                               tfile[termcount]);
+               MAIN_LEAKS();
                ExitProgram(EXIT_FAILURE);
            }
            repair_acsc(&entries[termcount].tterm);
                ExitProgram(EXIT_FAILURE);
            }
            repair_acsc(&entries[termcount].tterm);
@@ -1642,11 +1653,7 @@ main(int argc, char *argv[])
     else
        file_comparison(argc - optind, argv + optind);
 
     else
        file_comparison(argc - optind, argv + optind);
 
-#if NO_LEAKS
-    free(myargv);
-    free(tfile);
-    free(tname);
-#endif
+    MAIN_LEAKS();
     ExitProgram(EXIT_SUCCESS);
 }
 
     ExitProgram(EXIT_SUCCESS);
 }