Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/shmif_dumpbus Add some asserts to make sure the bus ...
details: https://anonhg.NetBSD.org/src/rev/27f07763d770
branches: trunk
changeset: 763102:27f07763d770
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Mar 10 10:11:25 2011 +0000
description:
Add some asserts to make sure the bus offset isn't beyond what we
mapped. (I had a very interesting time last night trying to figure
out what was going when things apparently got compiled with a 64bit
time_t on nb5. this caused only 4k of the bus file to be mapped...)
diffstat:
usr.bin/shmif_dumpbus/shmif_dumpbus.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diffs (46 lines):
diff -r d3d49e25333f -r 27f07763d770 usr.bin/shmif_dumpbus/shmif_dumpbus.c
--- a/usr.bin/shmif_dumpbus/shmif_dumpbus.c Thu Mar 10 10:06:33 2011 +0000
+++ b/usr.bin/shmif_dumpbus/shmif_dumpbus.c Thu Mar 10 10:11:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shmif_dumpbus.c,v 1.2 2011/03/09 12:56:08 pooka Exp $ */
+/* $NetBSD: shmif_dumpbus.c,v 1.3 2011/03/10 10:11:25 pooka Exp $ */
/*-
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -158,21 +158,26 @@
uint32_t oldoff;
bool wrap;
+ assert(curbus < sb.st_size);
+
wrap = false;
oldoff = curbus;
curbus = shmif_busread(bmem, &sp, oldoff, sizeof(sp), &wrap);
if (wrap)
bonus = 0;
- if (sp.sp_len == 0)
+ assert(curbus < sb.st_size);
+
+ if (sp.sp_len == 0) {
continue;
+ }
if (pfd != STDOUT_FILENO)
printf("packet %d, offset 0x%04x, length 0x%04x, "
"ts %d/%06d\n", i++, curbus,
sp.sp_len, sp.sp_sec, sp.sp_usec);
- if (!pcapfile || sp.sp_len == 0) {
+ if (!pcapfile) {
curbus = shmif_busread(bmem,
buf, curbus, sp.sp_len, &wrap);
if (wrap)
@@ -184,6 +189,7 @@
packhdr.caplen = packhdr.len = sp.sp_len;
packhdr.ts.tv_sec = sp.sp_sec;
packhdr.ts.tv_usec = sp.sp_usec;
+ assert(sp.sp_len <= BUFSIZE);
if (write(pfd, &packhdr, sizeof(packhdr)) != sizeof(packhdr))
err(1, "error writing packethdr");
Home |
Main Index |
Thread Index |
Old Index