[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Fri, 18 Aug 2023 08:28:12 -0400 (EDT) |
branch: master
commit 25584009e730d0a7872673fd43f641041546d2b5
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Aug 18 13:27:57 2023 +0100
* install-info/install-info.c (readfile): null-terminate file
data so to avoid reading off the end in mark_entry_for_deletion.
(mark_entry_for_deletion): Add checks for end of data.
---
ChangeLog | 6 ++++++
install-info/install-info.c | 12 +++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5221a62325..c7be40186c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-08-18 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * install-info/install-info.c (readfile): null-terminate file
+ data so to avoid reading off the end in mark_entry_for_deletion.
+ (mark_entry_for_deletion): Add checks for end of data.
+
2023-08-18 Gavin Smith <gavinsmith0123@gmail.com>
* install-info/install-info.c (output_dirfile): Avoid mixed
diff --git a/install-info/install-info.c b/install-info/install-info.c
index c7a21ff075..a3c4e3c747 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -893,7 +893,7 @@ readfile (char *filename, int *sizep,
break;
filled += nread;
- if (filled == data_size)
+ if (filled == data_size - 1)
{
data_size += 65536;
data = xrealloc (data, data_size);
@@ -909,6 +909,8 @@ readfile (char *filename, int *sizep,
fclose (f);
*sizep = filled;
+ data[filled] = '\0';
+
return data;
}
@@ -1349,9 +1351,13 @@ mark_entry_for_deletion (struct line_data *lines, int
nlines, char *name)
/* Read menu item. */
while (*p != 0 && *p != ':')
p++;
+ if (!*p)
+ continue;
p++; /* skip : */
- if (*p == ':')
+ if (!*p)
+ continue;
+ else if (*p == ':')
{ /* XEmacs-style entry, as in * Mew::Messaging. */
if (menu_item_equal (q, ':', name))
{
@@ -1365,7 +1371,7 @@ mark_entry_for_deletion (struct line_data *lines, int
nlines, char *name)
if (*p == '(') /* if at parenthesized (FILENAME) */
{
p++;
- if (menu_item_equal (p, ')', name))
+ if (*p && menu_item_equal (p, ')', name))
{
lines[i].delete = 1;
something_deleted = 1;