tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH 2/4] Fix alignment when reading core notes



Both desc and note header needs to be aligned.  Therefore, we need
to realign after skipping past desc as well.
---
 tests/lib/libc/sys/t_ptrace_wait.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/lib/libc/sys/t_ptrace_wait.c b/tests/lib/libc/sys/t_ptrace_wait.c
index 32e007d5e054..5ded0c311b7f 100644
--- a/tests/lib/libc/sys/t_ptrace_wait.c
+++ b/tests/lib/libc/sys/t_ptrace_wait.c
@@ -7728,6 +7728,9 @@ static ssize_t core_find_note(const char *core_path,
 			}
 
 			offset += note_hdr.n_descsz;
+			/* fix to alignment */
+			offset = ((offset + core_hdr.p_align - 1)
+			    / core_hdr.p_align) * core_hdr.p_align;
 		}
 	}
 
-- 
2.22.0



Home | Main Index | Thread Index | Old Index