From: Simon Schubert Date: Sat, 14 Jan 2006 22:58:18 +0000 (+0000) Subject: Fix use of history without HistEvent, causing segfaults X-Git-Tag: v2.0.1~5378 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/6d655b9a2e4b2becd6c41ec60243be0e0397bfed Fix use of history without HistEvent, causing segfaults Reported-by: esmith --- diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 010338a583..953078f62d 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -18,7 +18,7 @@ * Some code style reformatting. * * $FreeBSD: src/usr.sbin/cdcontrol/cdcontrol.c,v 1.24.2.11 2002/11/20 00:26:19 njl Exp $ - * $DragonFly: src/usr.sbin/cdcontrol/cdcontrol.c,v 1.9 2005/11/13 11:58:31 corecode Exp $ + * $DragonFly: src/usr.sbin/cdcontrol/cdcontrol.c,v 1.10 2006/01/14 22:58:17 corecode Exp $ */ #include @@ -1147,6 +1147,7 @@ input(int *cmd) #define MAXLINE 80 static EditLine *el = NULL; static History *hist = NULL; + static HistEvent he; static char buf[MAXLINE]; int num = 0; int len; @@ -1158,7 +1159,7 @@ input(int *cmd) if (!el) { el = el_init("cdcontrol", stdin, stdout, stderr); hist = history_init(); - history(hist, NULL, H_SETSIZE, 100); + history(hist, &he, H_SETSIZE, 100); el_set(el, EL_HIST, history, hist); el_set(el, EL_EDITOR, "emacs"); el_set(el, EL_PROMPT, cdcontrol_prompt); @@ -1174,7 +1175,7 @@ input(int *cmd) len = (num > MAXLINE) ? MAXLINE : num; memcpy(buf, bp, len); buf[len] = 0; - history(hist, NULL, H_ENTER, bp); + history(hist, &he, H_ENTER, bp); #undef MAXLINE } else { diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c index 7521f8d567..023786fe9e 100644 --- a/usr.sbin/lpr/lpc/lpc.c +++ b/usr.sbin/lpr/lpc/lpc.c @@ -34,7 +34,7 @@ * @(#) Copyright (c) 1983, 1993 The Regents of the University of California. All rights reserved. * @(#)lpc.c 8.3 (Berkeley) 4/28/95 * $FreeBSD: src/usr.sbin/lpr/lpc/lpc.c,v 1.13.2.11 2002/07/26 03:12:07 gad Exp $ - * $DragonFly: src/usr.sbin/lpr/lpc/lpc.c,v 1.6 2005/11/13 11:58:31 corecode Exp $ + * $DragonFly: src/usr.sbin/lpr/lpc/lpc.c,v 1.7 2006/01/14 22:58:18 corecode Exp $ */ #include @@ -143,6 +143,7 @@ cmdscanner(void) struct cmd *c; static EditLine *el; static History *hist; + static HistEvent he; size_t len; int num; const char *bp; @@ -156,7 +157,7 @@ cmdscanner(void) if (!el) { el = el_init("lpc", stdin, stdout, stderr); hist = history_init(); - history(hist, NULL, H_SETSIZE, 100); + history(hist, &he, H_SETSIZE, 100); el_set(el, EL_HIST, history, hist); el_set(el, EL_EDITOR, "emacs"); el_set(el, EL_PROMPT, lpc_prompt); @@ -178,7 +179,7 @@ cmdscanner(void) len = (num > MAX_CMDLINE -1) ? MAX_CMDLINE -1 : num; memcpy(cmdline, bp, len); cmdline[len] = 0; - history(hist, NULL, H_ENTER, bp); + history(hist, &he, H_ENTER, bp); } else { if (fgets(cmdline, MAX_CMDLINE, stdin) == 0) diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c index f46476850f..99bacd9e1a 100644 --- a/usr.sbin/pppctl/pppctl.c +++ b/usr.sbin/pppctl/pppctl.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/usr.sbin/pppctl/pppctl.c,v 1.21.2.2 2001/11/23 13:18:39 brian Exp $ - * $DragonFly: src/usr.sbin/pppctl/pppctl.c,v 1.6 2005/11/24 23:42:54 swildner Exp $ + * $DragonFly: src/usr.sbin/pppctl/pppctl.c,v 1.7 2006/01/14 22:58:18 corecode Exp $ */ #include @@ -393,6 +393,7 @@ main(int argc, char **argv) if (len == 0) { EditLine *edit; History *hist; + HistEvent he; const char *l, *env; int size; @@ -403,7 +404,7 @@ main(int argc, char **argv) size = 20; } else size = 20; - history(hist, NULL, H_SETSIZE, size); + history(hist, &he, H_SETSIZE, size); edit = el_init("pppctl", stdin, stdout, stderr); el_source(edit, NULL); el_set(edit, EL_PROMPT, GetPrompt); @@ -417,7 +418,7 @@ main(int argc, char **argv) el_set(edit, EL_HIST, history, (const char *)hist); while ((l = smartgets(edit, &len, fd))) { if (len > 1) - history(hist, NULL, H_ENTER, l); + history(hist, &he, H_ENTER, l); write(fd, l, len); if (Receive(fd, REC_SHOW) != 0) break;