Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/sys Fix alignment when reading core notes



details:   https://anonhg.NetBSD.org/src/rev/f1d1bdc69e35
branches:  trunk
changeset: 466990:f1d1bdc69e35
user:      mgorny <mgorny%NetBSD.org@localhost>
date:      Wed Jan 08 17:22:40 2020 +0000

description:
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.

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 0d25378773ec -r f1d1bdc69e35 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Wed Jan 08 17:21:38 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Wed Jan 08 17:22:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.145 2019/12/25 02:23:37 kamil Exp $        */
+/*     $NetBSD: t_ptrace_wait.c,v 1.146 2020/01/08 17:22:40 mgorny Exp $       */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.145 2019/12/25 02:23:37 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.146 2020/01/08 17:22:40 mgorny Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -7837,8 +7837,7 @@
 
                        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) {
@@ -7850,6 +7849,8 @@
                        }
 
                        offset += note_hdr.n_descsz;
+                       /* fix to alignment */
+                       offset = roundup(offset, core_hdr.p_align);
                }
        }
 



Home | Main Index | Thread Index | Old Index