summaryrefslogtreecommitdiff
path: root/lib/libedit/read.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2019-07-23 10:18:52 +0000
committerchristos <christos@NetBSD.org>2019-07-23 10:18:52 +0000
commit5439fdddbda55fffc2348d840a67d8fa35914b2d (patch)
treee64ac73f44bc4cf138a93e6faa0545d9d6508e59 /lib/libedit/read.c
parentd0d4388f4c0dff4fc2533cdd4920677859e0b914 (diff)
PR/54399: Sören Tempel: Uninitialized memory access in libedit history.
Initialize the buffer using calloc. While here change all malloc(a * sizeof(b)) to calloc(a, sizeof(b)). XXX: should fix realloc similarly.
Diffstat (limited to 'lib/libedit/read.c')
-rw-r--r--lib/libedit/read.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index 0d7dd9586e7..d2095a244ef 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.105 2018/11/25 16:21:04 christos Exp $ */
+/* $NetBSD: read.c,v 1.106 2019/07/23 10:18:52 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.105 2018/11/25 16:21:04 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.106 2019/07/23 10:18:52 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -89,8 +89,7 @@ read_init(EditLine *el)
return -1;
ma = &el->el_read->macros;
- if ((ma->macro = el_malloc(EL_MAXMACRO *
- sizeof(*ma->macro))) == NULL) {
+ if ((ma->macro = el_calloc(EL_MAXMACRO, sizeof(*ma->macro))) == NULL) {
free(el->el_read);
return -1;
}