From fa1298ce5bb867163f0ba131a102d14d8d88a59f Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 18 Jun 2020 10:26:54 +0000 Subject: Apply rules to the number of events returned by the last read(2). Fix a corner case where old events could be re-evaluated. From Yuichiro NAITO. --- usr.sbin/btrace/btrace.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index fdf2a5eeda8..9df58cf35a4 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.18 2020/04/24 14:56:43 mpi Exp $ */ +/* $OpenBSD: btrace.c,v 1.19 2020/06/18 10:26:53 mpi Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot @@ -338,15 +338,8 @@ rules_do(int fd) if ((rlen % sizeof(struct dt_evt)) != 0) err(1, "incorrect read"); - - for (i = 0; i < nitems(devtbuf); i++) { - struct dt_evt *dtev = &devtbuf[i]; - - if (dtev->dtev_tid == 0) - break; - - rules_apply(dtev); - } + for (i = 0; i < rlen / sizeof(struct dt_evt); i++) + rules_apply(&devtbuf[i]); } rules_teardown(fd); -- cgit v1.2.3