From bceadb8696f5145efa1b84bf90b579af7a09288e Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 26 Apr 2020 15:56:08 +0200 Subject: [PATCH] cansniffer: fix colorization when notching relevant bits When notching marked (and colored) bits with the interactive '#' command the binary output omits colored bits - as intended. But when switching back to the hex and ASCII output the bytes with notched bits remained uncolored even when some bits inside the hex bytes would have needed to be colored. The check for the colored output was a logical AND operation which is fine for the binary representation but needed to be a bit-wise operation in the hex/ASCII byte mode case. Signed-off-by: Oliver Hartkopp --- cansniffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cansniffer.c b/cansniffer.c index ccd6b4d..1a41b8a 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -646,7 +646,7 @@ void print_snifline(int id){ else { for (i=0; i 0x1F) && (sniftab[id].current.data[i] < 0x7F)) - if ((color) && (sniftab[id].marker.data[i]) && (!(sniftab[id].notch.data[i]))) + if ((color) && (sniftab[id].marker.data[i] & ~sniftab[id].notch.data[i])) printf("%s%c%s", ATTCOLOR, sniftab[id].current.data[i], ATTRESET); else putchar(sniftab[id].current.data[i]);