From ca62121c19c0eb7c78a46e0412784d904c78bd3c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 3 Mar 2022 17:38:31 +0100 Subject: [PATCH] host: Don't pass -1 (converted to 255) as address We initialize a local variable to -1, and if the user specifies no address from the command line, we use this in the interface match struct, which uses a uint8_t. This means 255 ends up in there, and as a result no usb interface ever matches unless the user explicitly specifies the -A command line argument. With this patch any absent -A argument will result in ifm.addr == 0, which means "don't match on address", and which is what we want here. Change-Id: Iffb5fa406ddef00c7c15570ffca2c109b98d7a2d --- host/src/simtrace2-cardem-pcsc.c | 3 ++- host/src/simtrace2-tool.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c index 0eaf2c3d..dabe693a 100644 --- a/host/src/simtrace2-cardem-pcsc.c +++ b/host/src/simtrace2-cardem-pcsc.c @@ -587,7 +587,8 @@ int main(int argc, char **argv) ifm->configuration = config_id; ifm->interface = if_num; ifm->altsetting = altsetting; - ifm->addr = addr; + if (addr > 0 && addr < 256) + ifm->addr = addr; if (path) osmo_strlcpy(ifm->path, path, sizeof(ifm->path)); transp->udp_fd = -1; diff --git a/host/src/simtrace2-tool.c b/host/src/simtrace2-tool.c index b0fac6c1..fdf0d566 100644 --- a/host/src/simtrace2-tool.c +++ b/host/src/simtrace2-tool.c @@ -309,7 +309,8 @@ int main(int argc, char **argv) ifm->configuration = config_id; ifm->interface = if_num; ifm->altsetting = altsetting; - ifm->addr = addr; + if (addr > 0 && addr < 256) + ifm->addr = addr; if (path) osmo_strlcpy(ifm->path, path, sizeof(ifm->path)); transp->usb_devh = osmo_libusb_open_claim_interface(NULL, NULL, ifm);