Subject: Re: lib/30552: small bug in libedit might cause abnormal program
To: Christos Zoulas <christos@zoulas.com>
From: =?ISO-8859-1?Q?Bj=F6rn_K=F6nig?= <bkoenig@cs.tu-berlin.de>
List: netbsd-bugs
Date: 06/21/2005 13:42:40
This is a multi-part message in MIME format.
--------------060209080002060908040400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

I'm sorry. Try this one instead of my previously sent patch.

Björn

--------------060209080002060908040400
Content-Type: text/x-patch;
 name="map.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="map.c.diff"

--- map.c.orig	Thu Aug  7 18:44:32 2003
+++ map.c	Tue Jun 21 13:39:24 2005
@@ -915,11 +915,20 @@
 	el->el_map.vic = el_map_vi_command;
 	el->el_map.vii = el_map_vi_insert;
 	el->el_map.help = (el_bindings_t *) el_malloc(sizeof(el_bindings_t) *
-	    EL_NUM_FCNS);
+	    (EL_NUM_FCNS + 1));
 	if (el->el_map.help == NULL)
 		return (-1);
+	/* set sizeof(el_bindings_t) more bytes to "1" ... */
+	(void) memset(el->el_map.help, 1, sizeof(el_bindings_t) * (EL_NUM_FCNS + 1));
+	/* ... but copy only N = EL_NUM_FCNS structures */
 	(void) memcpy(el->el_map.help, help__get(),
 	    sizeof(el_bindings_t) * EL_NUM_FCNS);
+	{
+		el_bindings_t *p = el->el_map.help;
+		for (;p->name;p++)
+			printf("%s\n", p->name);
+		printf("done\n");
+	}
 	el->el_map.func = (el_func_t *)el_malloc(sizeof(el_func_t) *
 	    EL_NUM_FCNS);
 	if (el->el_map.func == NULL)

--------------060209080002060908040400--