Module Name: src
Committed By: christos
Date: Sun Jul 6 18:15:34 UTC 2014
Modified Files:
src/lib/libedit: map.c map.h parse.c read.c
Log Message:
Bounds search for reallocated index, from OpenBSD via Andreas Fett
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/map.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libedit/map.h
cvs rdiff -u -r1.26 -r1.27 src/lib/libedit/parse.c
cvs rdiff -u -r1.70 -r1.71 src/lib/libedit/read.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/map.c
diff -u src/lib/libedit/map.c:1.33 src/lib/libedit/map.c:1.34
--- src/lib/libedit/map.c:1.33 Tue Jan 1 10:34:02 2013
+++ src/lib/libedit/map.c Sun Jul 6 14:15:34 2014
@@ -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 @@ protected int
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;
Index: src/lib/libedit/map.h
diff -u src/lib/libedit/map.h:1.9 src/lib/libedit/map.h:1.10
--- src/lib/libedit/map.h:1.9 Wed Dec 30 17:37:40 2009
+++ src/lib/libedit/map.h Sun Jul 6 14:15:34 2014
@@ -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 @@ typedef struct el_map_t {
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
Index: src/lib/libedit/parse.c
diff -u src/lib/libedit/parse.c:1.26 src/lib/libedit/parse.c:1.27
--- src/lib/libedit/parse.c:1.26 Tue Aug 16 12:25:15 2011
+++ src/lib/libedit/parse.c Sun Jul 6 14:15:34 2014
@@ -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 @@ parse__string(Char *out, const Char *in)
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;
}
Index: src/lib/libedit/read.c
diff -u src/lib/libedit/read.c:1.70 src/lib/libedit/read.c:1.71
--- src/lib/libedit/read.c:1.70 Mon May 27 19:55:55 2013
+++ src/lib/libedit/read.c Sun Jul 6 14:15:34 2014
@@ -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 @@ FUN(el,gets)(EditLine *el, int *nread)
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);