]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.9 - patch 20121229
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 30 Dec 2012 01:55:33 +0000 (01:55 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 30 Dec 2012 01:55:33 +0000 (01:55 +0000)
+ fix coverity warnings regarding copying into fixed-size buffers.
+ add throw-declarations in the c++ binding per Coverity warning.
+ minor changes to new-items for consistent reference to bug-report
  numbers.

17 files changed:
NEWS
c++/cursesf.h
c++/cursesm.h
c++/cursesp.h
c++/etip.h.in
dist.mk
ncurses/tinfo/captoinfo.c
ncurses/tinfo/write_entry.c
package/debian/changelog
package/ncurses.spec
progs/dump_entry.c
test/demo_defkey.c
test/demo_terminfo.c
test/gdc.c
test/ncurses.c
test/newdemo.c
test/view.c

diff --git a/NEWS b/NEWS
index a8d43aa13154260984f55666f8c408e30176b58a..f84b3fef09eaf97e6cfbcfaa4baf9ff8012ecaee 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.2002 2012/12/23 01:15:35 tom Exp $
+-- $Id: NEWS,v 1.2006 2012/12/29 22:37:28 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,12 @@ 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.
 
+20121229
+       + fix coverity warnings regarding copying into fixed-size buffers.
+       + add throw-declarations in the c++ binding per Coverity warning.
+       + minor changes to new-items for consistent reference to bug-report
+         numbers.
+
 20121222
        + add *.dSYM directories to clean-rule in ncurses directory makefile,
          for Mac OS builds.
@@ -2422,8 +2428,8 @@ it is not possible to add this information.
          that library.
        + add/modify null-pointer checks in several functions for SP and/or
          the WINDOW* parameter (report by Thorben Krueger).
-       + fixes for field_buffer() in formw library (see Redhat Bugzilla
-         #310071, patches by Miroslav Lichvar).
+       + fixes for field_buffer() in formw library (see Redhat #310071,
+         patches by Miroslav Lichvar).
        + improve performance of NCURSES_CHAR_EQ code (patch by Miroslav
          Lichvar).
        + update/improve mlterm and rxvt terminfo entries, e.g., for
@@ -3019,8 +3025,7 @@ it is not possible to add this information.
        + workaround for 20050806 ifdef's change to allow visbuf.c to compile
          when using --with-termlib --with-trace options.
        + improve tgetstr() by making the return value point into the user's
-         buffer, if provided (patch by Miroslav Lichvar (see Redhat Bugzilla
-         #202480)).
+         buffer, if provided (patch by Miroslav Lichvar (see Redhat #202480)).
        + correct libraries needed for foldkeys (report by Stanislav Ievlev)
 
 20060826
@@ -3033,10 +3038,10 @@ it is not possible to add this information.
          source output (Debian #378783).
        + modify configure script to ensure that if the C compiler is used
          rather than the loader in making shared libraries, the $(CFLAGS)
-         variable is also used (Redhat Bugzilla #199369).
+         variable is also used (Redhat #199369).
        + port hashed-db code to db2 and db3.
        + fix a bug in tgetent() from 20060625 and 20060715 changes
-         (patch/analysis by Miroslav Lichvar (see Redhat Bugzilla #202480)).
+         (patch/analysis by Miroslav Lichvar (see Redhat #202480)).
 
 20060805
        + updated xterm function-keys terminfo to match xterm #216 -TD
@@ -3828,7 +3833,7 @@ it is not possible to add this information.
          of cur_term if the same output was selected.  This now reuses it only
          when setupterm() is called from tgetent(), which has no notion of
          separate SCREENs.  Note that tgetent() must be called after initscr()
-         or newterm() to use this feature (Redhat Bugzilla #140326).
+         or newterm() to use this feature (Redhat #140326).
        + add a check in CF_BUILD_CC macro to ensure that developer has given
          the --with-build-cc option when cross-compiling (report by Alexandre
          Campo).
@@ -3921,7 +3926,7 @@ it is not possible to add this information.
          entries, e.g., so it can analyze the xterm-8bit entry.
        + add morphos terminfo entry, improve amiga-8bit entry (Pavel Fedin).
        + correct translation of "%%" in terminfo format to termcap, e.g.,
-         using "tic -C" (Redhat Bugzilla #130921).
+         using "tic -C" (Redhat #130921).
        + modified configure script CF_XOPEN_SOURCE macro to ensure that if
          it defines _POSIX_C_SOURCE, that it defines it to a specific value
          (comp.os.stratus newsgroup comment).
@@ -3932,9 +3937,9 @@ it is not possible to add this information.
          However that did find a coding error in Assume_Default_Colors().
        + modify several terminfo entries to ensure xterm mouse and cursor
          visibility are reset in rs2 string:  hurd, putty, gnome,
-         konsole-base, mlterm, Eterm, screen (Debian #265784, #55637).  The
-         xterm entries are left alone - old ones for compatibility, and the
-         new ones do not require this change. -TD
+         konsole-base, mlterm, Eterm, screen (Debian #265784, Debian #55637). 
+         The xterm entries are left alone - old ones for compatibility, and
+         the new ones do not require this change. -TD
 
 20040814
        + fake a SIGWINCH in newterm() to accommodate buggy terminal emulators
@@ -3965,8 +3970,8 @@ it is not possible to add this information.
        + modify "tic -cv" to ignore delays when comparing strings.  Also
          modify it to ignore a canceled sgr string, e.g., for terminals which
          cannot properly combine attributes in one control sequence.
-       + corrections for gnome and konsole entries (Redhat Bugzilla #122815,
-         patch by Hans de Goede)
+       + corrections for gnome and konsole entries (Redhat #122815, patch by
+         Hans de Goede)
        > terminfo updates -TD
        + make ncsa-m rmacs/smacs consistent with sgr
        + add sgr, rc/sc and ech to syscons entries
@@ -3979,7 +3984,7 @@ it is not possible to add this information.
        > terminfo updates -TD
        + add xterm-pc-fkeys
        + review/update gnome and gnome-rh90 entries (prompted by Redhat
-         Bugzilla #122815).
+         #122815).
        + review/update konsole entries
        + add sgr, correct sgr0 for kterm and mlterm
        + correct tsl string in kterm
@@ -5093,7 +5098,7 @@ it is not possible to add this information.
        + add a check in kgetch() for cooked characters in the fifo to avoid
          calling fifo_push() when a KEY_RESIZE is available (report/analysis
          by Sam Varshavchik <mrsam@courier-mta.com>).
-       + fix an overlooked case for bugzilla #68199 (Philippe Blain).
+       + fix an overlooked case for Redhat #68199 (Philippe Blain).
        + ensure clearerr() is called before using ferror() e.g., in
          lib_screen.c (report by Philippe Blain).
 
@@ -5101,7 +5106,7 @@ it is not possible to add this information.
        + modify lib_screen.c and lib_newwin.c to maintain the SCREEN-specific
          pointers for curscr/stdscr/newscr when scr_save() and scr_restore()
          modify the global curscr/stdscr/newscr variables.  Fixes Redhat
-         bugzilla #68199 dated 2002-07-07.
+         #68199 dated 2002-07-07.
        + add checks for null pointer in calls to tparm() and tgoto() based on
          FreeBSD bug report.  If ncurses were built with termcap support, and
          the first call to tgoto() were a zero-length string, the result would
@@ -5134,7 +5139,7 @@ it is not possible to add this information.
          Olaf Buddenhagen <olafBuddenhagen@web.de>).
        + modified wresize() to ensure that a failed realloc will not corrupt
          the window structure, and to make subwindows fit within the resized
-         window (completes Debian #87678, #101699)
+         window (completes Debian #87678, Debian #101699)
 
 20020803
        + fix an off-by-one in lib_pad.c check for limits of pad (patch by
@@ -5829,9 +5834,9 @@ it is not possible to add this information.
          which may be in libutf8.
        + remove some unnecessary text from curs_extend.3x and
          default_colors.3x which caused man-db to make incorrect symbolic
-         links (Debian bug report #99550).
+         links (Debian #99550).
        + add configure check if cast for _IO_va_list is needed to compile
-         C++ vscan code (Debian bug report #97945).
+         C++ vscan code (Debian #97945).
        > several patches from Sven Verdoolaege:
        + correct code that used non-standard auto-initialization of a struct,
          which gcc allows (report by Larry Virden).
@@ -5966,7 +5971,7 @@ it is not possible to add this information.
        + add some examples of customizing screen's terminfo:
          screen.xterm-xfree86, screen.xterm-r6, screen.teraterm -TD
        + modify screen's terminfo entry to match the khome/kend in screen
-         3.09.08 (Debian bug report #92215).
+         3.09.08 (Debian #92215).
        + correct a memory leak in forms library (report by Stefan Vogtner
          <stefan@vogtner.de>) (patch by Juergen Pfeifer).
 
@@ -5980,12 +5985,12 @@ it is not possible to add this information.
        + add .cc.ii rule to c++ makefile, to get preprocessor output for
          debugging.
        + correct configure script handling of @keyword@ substitutions when the
-         --with-manpage-renames option is given (cf:  20000715, fixes Debian
-         bug #89939).
+         --with-manpage-renames option is given (cf: 20000715, fixes Debian
+         #89939).
        + report stack underflow/overflow in tparm() when tic -cv option is
          given.
        + remove spurious "%|" operator from xterm-xfree86 terminfo entry,
-         (reported by Adam Costello <amc@cs.berkeley.edu>, Debian bug #89222).
+         (reported by Adam Costello <amc@cs.berkeley.edu>, Debian #89222).
 
 20010310
        + cleanup of newdemo.c, fixing some ambiguous expressions noted by gcc
@@ -6689,7 +6694,7 @@ it is not possible to add this information.
        + correct spelling error in terminfo entry name:  bq300-rv was given as
          bg300-rv in esr's version.
        + modify redrawwin() macro so its parameter is fully parenthesized
-         (fixes Debian bug report #61088).
+         (fixes Debian #61088).
        + correct formatting error in dump_entry() which set incorrect column
          value when no newline trimming was needed at the end of an entry,
          before appending "use=" clauses (cf: 960406).
index 23bc0f5b0f5c3ff34a4161988b25558d80af44a8..ef705413720519e185ea6b6f30d6fb8d98dd3408 100644 (file)
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesf.h,v 1.30 2012/06/08 17:43:56 Richard.Yao Exp $
+// $Id: cursesf.h,v 1.31 2012/12/29 21:49:58 tom Exp $
 
 #ifndef NCURSES_CURSESF_H_incl
 #define NCURSES_CURSESF_H_incl 1
@@ -61,7 +61,7 @@ class NCURSES_IMPEXP NCursesFieldType
 protected:
   FIELDTYPE* fieldtype;
 
-  inline void OnError(int err) const THROWS(NCursesFormException) {
+  inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) {
     if (err!=E_OK)
       THROW(new NCursesFormException (err));
   }
@@ -109,7 +109,7 @@ protected:
   NCursesFieldType* ftype;   // Associated field type
 
   // Error handler
-  inline void OnError (int err) const THROWS(NCursesFormException) {
+  inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
     if (err != E_OK)
       THROW(new NCursesFormException (err));
   }
@@ -391,7 +391,7 @@ protected:
                 bool with_frame,
                 bool autoDeleteFields);
 
-  inline void OnError (int err) const THROWS(NCursesFormException) {
+  inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
     if (err != E_OK)
       THROW(new NCursesFormException (err));
   }
index 45b6c0cc73be5496d434773263b2779040cab51c..259d107fb447728bedf4b7b6d273266fad57ed8f 100644 (file)
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesm.h,v 1.28 2012/06/08 17:43:56 Richard.Yao Exp $
+// $Id: cursesm.h,v 1.29 2012/12/29 21:48:33 tom Exp $
 
 #ifndef NCURSES_CURSESM_H_incl
 #define NCURSES_CURSESM_H_incl 1
@@ -53,7 +53,7 @@ class NCURSES_IMPEXP NCursesMenuItem
 protected:
   ITEM *item;
 
-  inline void OnError (int err) const THROWS(NCursesMenuException) {
+  inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
     if (err != E_OK)
       THROW(new NCursesMenuException (err));
   }
@@ -253,7 +253,7 @@ protected:
                 bool with_frame,
                 bool autoDeleteItems);
 
-  inline void OnError (int err) const THROWS(NCursesMenuException) {
+  inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
     if (err != E_OK)
       THROW(new NCursesMenuException (this, err));
   }
index 9b63d6d671bfd6be7ad516a991c31a8f1db311f6..699ec284fcfd29906e98cab0b3c7271387bc3fec 100644 (file)
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2012 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 @@
 #ifndef NCURSES_CURSESP_H_incl
 #define NCURSES_CURSESP_H_incl 1
 
-// $Id: cursesp.h,v 1.29 2008/08/16 17:20:23 tom Exp $
+// $Id: cursesp.h,v 1.30 2012/12/29 21:50:55 tom Exp $
 
 #include <cursesw.h>
 
@@ -86,7 +86,7 @@ protected:
     return result;
   }
 
-  void OnError (int err) const THROWS(NCursesPanelException)
+  void OnError (int err) const THROW2(NCursesException const, NCursesPanelException)
   {
     if (err==ERR)
       THROW(new NCursesPanelException (this, err));
index b78bc9bf708c4a08744f886ea81a0d5c9443fec8..9f642ee6d0008b4be25cde0970aa42bce74bc055 100644 (file)
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2008,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2011,2012 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            *
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: etip.h.in,v 1.38 2011/10/29 14:01:50 tom Exp $
+// $Id: etip.h.in,v 1.39 2012/12/29 21:50:44 tom Exp $
 
 #ifndef NCURSES_ETIP_H_incl
 #define NCURSES_ETIP_H_incl 1
@@ -367,11 +367,13 @@ inline void THROW(const NCursesException *e) {
 #define NCURSES_CPP_TRY                /* nothing */
 #define NCURSES_CPP_CATCH(e)   if (false)
 #define THROWS(s)              /* nothing */
+#define THROW2(s,t)            /* nothing */
 #elif CPP_HAS_TRY_CATCH
   throw *e;
 #define NCURSES_CPP_TRY                try
 #define NCURSES_CPP_CATCH(e)   catch(e)
 #define THROWS(s)              throw(s)
+#define THROW2(s,t)            throw(s,t)
 #endif
 }
 
diff --git a/dist.mk b/dist.mk
index 524f7c08e204fa19bb8ce5ab90cd73d9f2449d53..e3b7cab9aa017a22ed31727048260d1d28e5ad66 100644 (file)
--- 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.906 2012/12/22 17:51:44 tom Exp $
+# $Id: dist.mk,v 1.907 2012/12/29 16:59:31 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 = 20121222
+NCURSES_PATCH = 20121229
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index db46e2096903912075e52385c377ac0928ad632a..e02e622b0de3ee94ec710d9f08df26708656f6ce 100644 (file)
@@ -93,7 +93,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.75 2012/11/24 20:48:54 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.77 2012/12/30 00:50:40 tom Exp $")
 
 #define MAX_PUSHED     16      /* max # args we can push onto the stack */
 
@@ -532,10 +532,13 @@ save_tc_char(char *bufptr, int c1)
            bufptr = save_char(bufptr, '\\');
        bufptr = save_char(bufptr, c1);
     } else {
-       if (c1 == (c1 & 0x1f))  /* iscntrl() returns T on 255 */
-           _nc_STRCPY(temp, unctrl((chtype) c1), sizeof(temp));
-       else
-           _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "\\%03o", c1);
+       if (c1 == (c1 & 0x1f)) {        /* iscntrl() returns T on 255 */
+           _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+                       "%.20s", unctrl((chtype) c1));
+       } else {
+           _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+                       "\\%03o", c1);
+       }
        bufptr = save_string(bufptr, temp);
     }
     return bufptr;
index 9fdfe59d97113c955b65478a772a9e725f15822f..45f315977daad89f7be3534ba7d39d61c926cd5d 100644 (file)
@@ -47,7 +47,7 @@
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.86 2012/06/16 16:59:05 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.87 2012/12/29 23:12:22 tom Exp $")
 
 static int total_written;
 
@@ -273,16 +273,21 @@ _nc_write_entry(TERMTYPE *const tp)
     char name_list[MAX_TERMINFO_LENGTH];
     char *first_name, *other_names;
     char *ptr;
+    const char *term_names = tp->term_names;
+    size_t name_size = strlen(term_names);
 
-    assert(strlen(tp->term_names) != 0);
-    assert(strlen(tp->term_names) < sizeof(name_list));
+    if (name_size == 0) {
+       _nc_syserr_abort("no terminal name found.");
+    } else if (name_size >= sizeof(name_list) - 1) {
+       _nc_syserr_abort("terminal name too long: %s", term_names);
+    }
 
-    _nc_STRCPY(name_list, tp->term_names, sizeof(name_list));
+    _nc_STRCPY(name_list, term_names, sizeof(name_list));
     DEBUG(7, ("Name list = '%s'", name_list));
 
     first_name = name_list;
 
-    ptr = &name_list[strlen(name_list) - 1];
+    ptr = &name_list[name_size - 1];
     other_names = ptr + 1;
 
     while (ptr > name_list && *ptr != '|')
@@ -316,8 +321,8 @@ _nc_write_entry(TERMTYPE *const tp)
            buffer[0] = 0;
 
            memset(&key, 0, sizeof(key));
-           key.data = tp->term_names;
-           key.size = strlen(tp->term_names);
+           key.data = term_names;
+           key.size = name_size;
 
            memset(&data, 0, sizeof(data));
            data.data = buffer;
@@ -328,12 +333,12 @@ _nc_write_entry(TERMTYPE *const tp)
            buffer[0] = 2;
 
            key.data = name_list;
-           key.size = strlen(name_list);
+           key.size = name_size;
 
            _nc_STRCPY(buffer + 1,
-                      tp->term_names,
+                      term_names,
                       sizeof(buffer) - 1);
-           data.size = strlen(tp->term_names) + 1;
+           data.size = name_size + 1;
 
            _nc_db_put(capdb, &key, &data);
 
index 0cee29a5c94b461b297d2bc9d1056f99935edc48..c4a7623da0e59f5995d55072aadbf49d4f4dd420 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20121222) unstable; urgency=low
+ncurses6 (5.9-20121229) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 22 Dec 2012 12:57:01 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 29 Dec 2012 12:00:04 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
index 5577edf1140896b6ce381590c9a4b61726dfae33..270a686205e76b2e0399369f9bd1719a0eadf33e 100644 (file)
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Release: 5.9
-Version: 20121222
+Version: 20121229
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{release}-%{version}.tgz
index 56610e9db2b0decc4488f96c4d4b3ce027cdbe97..99f3b2a83900520cbac17458e933863cda707210 100644 (file)
@@ -39,7 +39,7 @@
 #include "termsort.c"          /* this C file is generated */
 #include <parametrized.h>      /* so is this */
 
-MODULE_ID("$Id: dump_entry.c,v 1.102 2012/12/15 18:25:56 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.104 2012/12/30 00:51:13 tom Exp $")
 
 #define INDENT                 8
 #define DISCARD(string) string = ABSENT_STRING
@@ -873,11 +873,41 @@ fmt_entry(TERMTYPE *tterm,
            tp[0] = '\0';
 
            if (box_ok) {
+               char *tmp = _nc_tic_expand(boxchars,
+                                          (outform == F_TERMINFO),
+                                          numbers);
                _nc_STRCPY(buffer, "box1=", sizeof(buffer));
-               _nc_STRCAT(buffer,
-                          _nc_tic_expand(boxchars,
-                                         outform == F_TERMINFO, numbers),
-                          sizeof(buffer));
+               while (*tmp != '\0') {
+                   size_t have = strlen(buffer);
+                   size_t next = strlen(tmp);
+                   size_t want = have + next + 1;
+                   size_t last = next;
+                   char save = '\0';
+
+                   /*
+                    * If the expanded string is too long for the buffer,
+                    * chop it off and save the location where we chopped it.
+                    */
+                   if (want >= sizeof(buffer)) {
+                       save = tmp[last];
+                       tmp[last] = '\0';
+                   }
+                   _nc_STRCAT(buffer, tmp, sizeof(buffer));
+
+                   /*
+                    * If we chopped the buffer, replace the missing piece and
+                    * shift everything to append the remainder.
+                    */
+                   if (save != '\0') {
+                       next = 0;
+                       tmp[last] = save;
+                       while ((tmp[next] = tmp[last + next]) != '\0') {
+                           ++next;
+                       }
+                   } else {
+                       break;
+                   }
+               }
                WRAP_CONCAT;
            }
        }
index ac6dc2df79e8fc3c467b5232f88d87454b64f1da..03c4d622576710ec95023085b0ff7e847a2c654b 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 2002-2008,2012 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            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_defkey.c,v 1.20 2010/11/14 00:59:35 tom Exp $
+ * $Id: demo_defkey.c,v 1.21 2012/12/29 22:55:39 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2002/11/23
@@ -106,7 +106,7 @@ visible(const char *string)
        for (pass = 0; pass < 2; ++pass) {
            for (n = 0; string[n] != '\0'; ++n) {
                char temp[80];
-               strcpy(temp, visichar(string[n]));
+               strncpy(temp, visichar(string[n]), sizeof(temp) - 2);
                if (pass)
                    strcat(result, temp);
                else
index 8b64869f1c2aae4e35e3540a5a7ae36abc475f3e..d9bf5540b60f0c9df221debfe737b76d55f982ee 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_terminfo.c,v 1.13 2012/07/07 23:37:13 tom Exp $
+ * $Id: demo_terminfo.c,v 1.15 2012/12/29 23:36:22 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
@@ -283,7 +283,7 @@ demo_terminfo(char *name)
            }
 #endif
        } else {
-           char temp[10];
+           char temp[80];
            static const char *xterm_keys[] =
            {
                "kDC", "kDN", "kEND", "kHOM", "kIC",
@@ -292,9 +292,9 @@ demo_terminfo(char *name)
            for (n = 0; n < SIZEOF(xterm_keys); ++n) {
                for (mod = 0; mod < 8; ++mod) {
                    if (mod == 0)
-                       strcpy(temp, xterm_keys[n]);
+                       sprintf(temp, "%.*s", 8, xterm_keys[n]);
                    else
-                       sprintf(temp, "%s%d", xterm_keys[n], mod);
+                       sprintf(temp, "%.*s%d", 8, xterm_keys[n], mod);
                    dumpit(temp);
                }
            }
index 0a925b4ede04b4556865f4ff27a68a2f1ee5d328..4c662ecf73ef636c42027539a9f928968c95315b 100644 (file)
@@ -33,7 +33,7 @@
  * modified 10-18-89 for curses (jrl)
  * 10-18-89 added signal handling
  *
- * $Id: gdc.c,v 1.35 2012/06/09 20:30:32 tom Exp $
+ * $Id: gdc.c,v 1.36 2012/12/29 22:51:57 tom Exp $
  */
 
 #include <test.priv.h>
@@ -231,7 +231,7 @@ main(int argc, char *argv[])
     drawbox(FALSE);
 
     do {
-       char buf[30];
+       char buf[40];
 
        time(&now);
        tm = localtime(&now);
@@ -293,7 +293,7 @@ main(int argc, char *argv[])
        }
 
        /* this depends on the detailed format of ctime(3) */
-       (void) strcpy(buf, ctime(&now));
+       (void) strncpy(buf, ctime(&now), 30);
        (void) strcpy(buf + 10, buf + 19);
        MvAddStr(16, 30, buf);
 
index 9810bce3858fb4cd77a56d072e988f7d4c2754b7..15f732964e8b950eb671780afd48b4929ee8bc94 100644 (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.382 2012/12/09 00:56:24 tom Exp $
+$Id: ncurses.c,v 1.386 2012/12/29 23:37:55 tom Exp $
 
 ***************************************************************************/
 
@@ -1919,7 +1919,7 @@ show_color_name(int y, int x, int color, bool wide)
        } else if (color < 0) {
            strcpy(temp, "default");
        } else {
-           strcpy(temp, the_color_names[color]);
+           sprintf(temp, "%.*s", 16, the_color_names[color]);
        }
        printw("%-*.*s", width, width, temp);
     }
@@ -3728,7 +3728,7 @@ show_2_wacs(int n, const char *name, const char *code, attr_t attr, short pair)
 
     MvPrintw(row, col, "%*s : ", COLS / 4, name);
     (void) attr_set(attr, pair, 0);
-    addstr(strcpy(temp, code));
+    addstr(strncpy(temp, code, 20));
     (void) attr_set(A_NORMAL, 0, 0);
     return n + 1;
 }
@@ -5786,55 +5786,60 @@ edit_secure(FIELD * me, int c)
     if (field_info(me, &rows, &cols, &frow, &fcol, &nrow, &nbuf) == E_OK
        && nbuf > 0) {
        char *source = field_buffer(me, 1);
-       char temp[80];
+       size_t have = (source ? strlen(source) : 0) + 1;
+       size_t need = 80 + have;
+       char *temp = malloc(need);
        long len;
 
-       strcpy(temp, source ? source : "");
-       len = (long) (char *) field_userptr(me);
-       if (c <= KEY_MAX) {
-           if (isgraph(c) && (len + 1) < (int) sizeof(temp)) {
-               temp[len++] = (char) c;
-               temp[len] = 0;
-               set_field_buffer(me, 1, temp);
-               c = '*';
-           } else {
-               c = 0;
-           }
-       } else {
-           switch (c) {
-           case REQ_BEG_FIELD:
-           case REQ_CLR_EOF:
-           case REQ_CLR_EOL:
-           case REQ_DEL_LINE:
-           case REQ_DEL_WORD:
-           case REQ_DOWN_CHAR:
-           case REQ_END_FIELD:
-           case REQ_INS_CHAR:
-           case REQ_INS_LINE:
-           case REQ_LEFT_CHAR:
-           case REQ_NEW_LINE:
-           case REQ_NEXT_WORD:
-           case REQ_PREV_WORD:
-           case REQ_RIGHT_CHAR:
-           case REQ_UP_CHAR:
-               c = 0;          /* we don't want to do inline editing */
-               break;
-           case REQ_CLR_FIELD:
-               if (len) {
-                   temp[0] = 0;
+       if (temp != 0) {
+           strncpy(temp, source ? source : "", have + 1);
+           len = (long) (char *) field_userptr(me);
+           if (c <= KEY_MAX) {
+               if (isgraph(c) && (len + 1) < (int) sizeof(temp)) {
+                   temp[len++] = (char) c;
+                   temp[len] = 0;
                    set_field_buffer(me, 1, temp);
+                   c = '*';
+               } else {
+                   c = 0;
                }
-               break;
-           case REQ_DEL_CHAR:
-           case REQ_DEL_PREV:
-               if (len) {
-                   temp[--len] = 0;
-                   set_field_buffer(me, 1, temp);
+           } else {
+               switch (c) {
+               case REQ_BEG_FIELD:
+               case REQ_CLR_EOF:
+               case REQ_CLR_EOL:
+               case REQ_DEL_LINE:
+               case REQ_DEL_WORD:
+               case REQ_DOWN_CHAR:
+               case REQ_END_FIELD:
+               case REQ_INS_CHAR:
+               case REQ_INS_LINE:
+               case REQ_LEFT_CHAR:
+               case REQ_NEW_LINE:
+               case REQ_NEXT_WORD:
+               case REQ_PREV_WORD:
+               case REQ_RIGHT_CHAR:
+               case REQ_UP_CHAR:
+                   c = 0;      /* we don't want to do inline editing */
+                   break;
+               case REQ_CLR_FIELD:
+                   if (len) {
+                       temp[0] = 0;
+                       set_field_buffer(me, 1, temp);
+                   }
+                   break;
+               case REQ_DEL_CHAR:
+               case REQ_DEL_PREV:
+                   if (len) {
+                       temp[--len] = 0;
+                       set_field_buffer(me, 1, temp);
+                   }
+                   break;
                }
-               break;
            }
+           set_field_userptr(me, (void *) len);
+           free(temp);
        }
-       set_field_userptr(me, (void *) len);
     }
     return c;
 }
index 566fc47c6a6c756a1feec8c2a6b9cf1119bdc0f3..825d6e4624569d9dc42a1aea3abc0f439b7ab942 100644 (file)
@@ -2,7 +2,7 @@
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
- * $Id: newdemo.c,v 1.37 2012/11/17 23:27:50 tom Exp $
+ * $Id: newdemo.c,v 1.39 2012/12/29 23:39:08 tom Exp $
  */
 
 #include <test.priv.h>
@@ -222,7 +222,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
     WINDOW *win;
     int w, x, y, i, j, k;
-    char buffer[200];
+    char buffer[SIZEOF(messages) * 80];
     const char *message;
     int width, height;
     chtype save[80];
index 6a3c75072767a26029260d380330a0f4791396d7..76a88a3096aeea8ac99f8b4721e3198048f724ae 100644 (file)
@@ -50,7 +50,7 @@
  * scroll operation worked, and the refresh() code only had to do a
  * partial repaint.
  *
- * $Id: view.c,v 1.88 2012/12/01 23:19:49 tom Exp $
+ * $Id: view.c,v 1.89 2012/12/29 22:38:28 tom Exp $
  */
 
 #include <test.priv.h>
@@ -565,7 +565,7 @@ show_all(const char *tag)
     printw("%.*s", COLS, temp);
     clrtoeol();
     this_time = time((time_t *) 0);
-    strcpy(temp, ctime(&this_time));
+    strncpy(temp, ctime(&this_time), 30);
     if ((i = (int) strlen(temp)) != 0) {
        temp[--i] = 0;
        if (move(0, COLS - i - 2) != ERR)