[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 26/41] boot: Fix use-after-realloc
From: |
Sergey Bugaev |
Subject: |
[PATCH 26/41] boot: Fix use-after-realloc |
Date: |
Tue, 9 May 2023 00:31:21 +0300 |
---
boot/boot.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/boot/boot.c b/boot/boot.c
index b661f09c..144ca1c3 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -486,15 +486,16 @@ read_boot_script (char **buffer, size_t *length)
if (p == buf + len)
{
char *newbuf;
+ size_t newlen = len + 500;
- len += 500;
- newbuf = realloc (buf, len);
+ newbuf = realloc (buf, newlen);
if (!newbuf)
{
write (2, memmsg, sizeof (memmsg));
host_exit (1);
}
- p = newbuf + (p - buf);
+ p = newbuf + len;
+ len = newlen;
buf = newbuf;
}
}
--
2.40.1
- [PATCH 12/41] libps: Silence a warning, (continued)
- [PATCH 11/41] libps: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 32/41] tmpfs: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 29/41] pflocal: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 14/41] utils: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 17/41] proc: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 16/41] auth: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 26/41] boot: Fix use-after-realloc,
Sergey Bugaev <=
- [PATCH 20/41] elfcore: Add support for saving x86_64 registers, Sergey Bugaev, 2023/05/08
- [PATCH 22/41] sutils: Avoid warnings about prototype mismatch, Sergey Bugaev, 2023/05/08
- [PATCH 35/41] procfs: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 41/41] Style tweaks, Sergey Bugaev, 2023/05/08
- [PATCH 34/41] ext2fs: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 33/41] fatfs: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 21/41] sutils: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 27/41] boot: Port to x64_64, Sergey Bugaev, 2023/05/08
- [PATCH 37/41] console-client: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 30/41] startup: Port to x86_64, Sergey Bugaev, 2023/05/08