[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 18/41] proc: Fix use-after-realloc
From: |
Sergey Bugaev |
Subject: |
[PATCH 18/41] proc: Fix use-after-realloc |
Date: |
Tue, 9 May 2023 00:31:13 +0300 |
---
proc/info.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/proc/info.c b/proc/info.c
index 12743465..d84fdd45 100644
--- a/proc/info.c
+++ b/proc/info.c
@@ -941,6 +941,8 @@ S_proc_getloginpids (struct proc *callerp,
if (new - parray > parraysize)
{
struct proc **newparray;
+ ptrdiff_t tail_offset = tail - parray;
+ ptrdiff_t new_offset = new - parray;
newparray = realloc (parray, ((parraysize *= 2)
* sizeof (struct proc *)));
if (! newparray)
@@ -949,8 +951,8 @@ S_proc_getloginpids (struct proc *callerp,
return ENOMEM;
}
- tail = newparray + (tail - parray);
- new = newparray + (new - parray);
+ tail = newparray + tail_offset;
+ new = newparray + new_offset;
parray = newparray;
}
*new++ = p;
--
2.40.1
- [PATCH 22/41] sutils: Avoid warnings about prototype mismatch, (continued)
- [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
- [PATCH 15/41] utils: Avoid warnings about prototype mismatch, Sergey Bugaev, 2023/05/08
- [PATCH 18/41] proc: Fix use-after-realloc,
Sergey Bugaev <=
- [PATCH 31/41] mach-defpager: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 38/41] trans: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 19/41] exec: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 25/41] daemons: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 40/41] Disable Linux-based pfinet on x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 23/41] storeio: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 24/41] devnode: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 39/41] Look for mach_i386 in mach/machine/, Sergey Bugaev, 2023/05/08
- [PATCH 36/41] term: Port to x86_64, Sergey Bugaev, 2023/05/08
- [PATCH 28/41] eth-multiplexer: Port to x86_64, Sergey Bugaev, 2023/05/08