tech-kern archive

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

[PATCH v5 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.

While at it, fix the other alignment fix to use roundup() macro.
---
 tests/lib/libc/sys/t_ptrace_wait.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Changes in v5:
- use roundup() to align offsets.

diff --git a/tests/lib/libc/sys/t_ptrace_wait.c b/tests/lib/libc/sys/t_ptrace_wait.c
index 6fc43572e015..b20c94295326 100644
--- a/tests/lib/libc/sys/t_ptrace_wait.c
+++ b/tests/lib/libc/sys/t_ptrace_wait.c
@@ -7590,8 +7590,7 @@ static ssize_t core_find_note(const char *core_path,
 
 			offset += note_hdr.n_namesz;
 			/* fix to alignment */
-			offset = ((offset + core_hdr.p_align - 1)
-			    / core_hdr.p_align) * core_hdr.p_align;
+			offset = roundup(offset, core_hdr.p_align);
 
 			/* if name & type matched above */
 			if (ret != -1) {
@@ -7603,6 +7602,8 @@ static ssize_t core_find_note(const char *core_path,
 			}
 
 			offset += note_hdr.n_descsz;
+			/* fix to alignment */
+			offset = roundup(offset, core_hdr.p_align);
 		}
 	}
 
-- 
2.24.1



Home | Main Index | Thread Index | Old Index