Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Check the CTF magic number in an endian friendly wa...
details: https://anonhg.NetBSD.org/src/rev/d01253cfd734
branches: trunk
changeset: 961013:d01253cfd734
user: simonb <simonb%NetBSD.org@localhost>
date: Tue Apr 06 07:57:03 2021 +0000
description:
Check the CTF magic number in an endian friendly way (and don't use
magic numbers to check the magic number!).
diffstat:
sys/kern/kern_ctf.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (29 lines):
diff -r e89006d2cb1a -r d01253cfd734 sys/kern/kern_ctf.c
--- a/sys/kern/kern_ctf.c Tue Apr 06 07:56:10 2021 +0000
+++ b/sys/kern/kern_ctf.c Tue Apr 06 07:57:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ctf.c,v 1.7 2018/05/28 21:05:00 chs Exp $ */
+/* $NetBSD: kern_ctf.c,v 1.8 2021/04/06 07:57:03 simonb Exp $ */
/*-
* Copyright (c) 2008 John Birrell <jb%freebsd.org@localhost>
* All rights reserved.
@@ -81,6 +81,7 @@
void *ctfbuf = NULL;
uint8_t *ctfaddr;
+ uint16_t ctfmagic;
size_t ctfsize;
/*
@@ -137,8 +138,9 @@
goto out;
}
- /* Check the CTF magic number. (XXX check for big endian!) */
- if (ctfaddr[0] != 0xf1 || ctfaddr[1] != 0xcf) {
+ /* Check the CTF magic number. */
+ memcpy(&ctfmagic, ctfaddr, sizeof ctfmagic);
+ if (ctfmagic != CTF_MAGIC) {
error = EINVAL;
goto out;
}
Home |
Main Index |
Thread Index |
Old Index