Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit Bounds search for reallocated index, from OpenBS...



details:   https://anonhg.NetBSD.org/src/rev/50afb943d946
branches:  trunk
changeset: 330377:50afb943d946
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jul 06 18:15:34 2014 +0000

description:
Bounds search for reallocated index, from OpenBSD via Andreas Fett

diffstat:

 lib/libedit/map.c   |   6 +++---
 lib/libedit/map.h   |   4 ++--
 lib/libedit/parse.c |  13 +++++++------
 lib/libedit/read.c  |   6 +++---
 4 files changed, 15 insertions(+), 14 deletions(-)

diffs (106 lines):

diff -r 308144692afc -r 50afb943d946 lib/libedit/map.c
--- a/lib/libedit/map.c Sun Jul 06 18:09:04 2014 +0000
+++ b/lib/libedit/map.c Sun Jul 06 18:15:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: map.c,v 1.33 2013/01/01 15:34:02 christos Exp $        */
+/*     $NetBSD: map.c,v 1.34 2014/07/06 18:15:34 christos Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)map.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: map.c,v 1.33 2013/01/01 15:34:02 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.34 2014/07/06 18:15:34 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -1396,7 +1396,7 @@
 map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func)
 {
        void *p;
-       size_t nf = (size_t)el->el_map.nfunc + 1;
+       size_t nf = el->el_map.nfunc + 1;
 
        if (name == NULL || help == NULL || func == NULL)
                return -1;
diff -r 308144692afc -r 50afb943d946 lib/libedit/map.h
--- a/lib/libedit/map.h Sun Jul 06 18:09:04 2014 +0000
+++ b/lib/libedit/map.h Sun Jul 06 18:15:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: map.h,v 1.9 2009/12/30 22:37:40 christos Exp $ */
+/*     $NetBSD: map.h,v 1.10 2014/07/06 18:15:34 christos Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -57,7 +57,7 @@
        int              type;          /* Emacs or vi                  */
        el_bindings_t   *help;          /* The help for the editor functions */
        el_func_t       *func;          /* List of available functions  */
-       int              nfunc;         /* The number of functions/help items */
+       size_t           nfunc;         /* The number of functions/help items */
 } el_map_t;
 
 #define        MAP_EMACS       0
diff -r 308144692afc -r 50afb943d946 lib/libedit/parse.c
--- a/lib/libedit/parse.c       Sun Jul 06 18:09:04 2014 +0000
+++ b/lib/libedit/parse.c       Sun Jul 06 18:15:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.26 2011/08/16 16:25:15 christos Exp $      */
+/*     $NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $      */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)parse.c    8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: parse.c,v 1.26 2011/08/16 16:25:15 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -276,10 +276,11 @@
 protected int
 parse_cmd(EditLine *el, const Char *cmd)
 {
-       el_bindings_t *b;
+       el_bindings_t *b = el->el_map.help;
+       size_t i;
 
-       for (b = el->el_map.help; b->name != NULL; b++)
-               if (Strcmp(b->name, cmd) == 0)
-                       return b->func;
+       for (i = 0; i < el->el_map.nfunc; i++)
+               if (Strcmp(b[i].name, cmd) == 0)
+                       return b[i].func;
        return -1;
 }
diff -r 308144692afc -r 50afb943d946 lib/libedit/read.c
--- a/lib/libedit/read.c        Sun Jul 06 18:09:04 2014 +0000
+++ b/lib/libedit/read.c        Sun Jul 06 18:15:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.c,v 1.70 2013/05/27 23:55:55 christos Exp $       */
+/*     $NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)read.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: read.c,v 1.70 2013/05/27 23:55:55 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -597,7 +597,7 @@
                            el->el_line.cursor = el->el_line.buffer;
                        break;
                }
-               if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) {   /* BUG CHECK command */
+               if ((size_t)cmdnum >= el->el_map.nfunc) {       /* BUG CHECK command */
 #ifdef DEBUG_EDIT
                        (void) fprintf(el->el_errfile,
                            "ERROR: illegal command from key 0%o\r\n", ch);



Home | Main Index | Thread Index | Old Index