diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-05-09 00:31:21 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-10 02:38:53 +0200 |
commit | 202585da4315df1c68e6619d8097b06aaac98bbc (patch) | |
tree | 1f51f05ec2091bae8b32b1a988f5e6edb3fa0ab5 /boot | |
parent | c9d6d69973ff6f11cc4a4428505b1e34ecde3b33 (diff) | |
download | hurd-202585da4315df1c68e6619d8097b06aaac98bbc.tar.gz hurd-202585da4315df1c68e6619d8097b06aaac98bbc.tar.bz2 hurd-202585da4315df1c68e6619d8097b06aaac98bbc.zip |
boot: Fix use-after-realloc
Message-Id: <20230508213136.608575-27-bugaevc@gmail.com>
Diffstat (limited to 'boot')
-rw-r--r-- | boot/boot.c | 7 |
1 files 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; } } |