From 732c894a51d8516214b565e7258446bdfc9f09e3 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Tue, 20 Aug 2024 22:34:37 +0200 Subject: [PATCH] CLI: make mfkey32v2 Windows friendly --- software/src/mfkey32v2.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/software/src/mfkey32v2.c b/software/src/mfkey32v2.c index a2308200..567a2d3c 100644 --- a/software/src/mfkey32v2.c +++ b/software/src/mfkey32v2.c @@ -101,19 +101,11 @@ int main(int argc, char *argv[]) { return 0; } else if (argc == 2 && ! strncmp(argv[1], "--server", 9)) { - char *line =NULL; - size_t len = 0; - ssize_t line_size; - while(true) { - line_size = getline(&line, &len, stdin); - if (line_size > 1) { - sscanf(line, "%x %x %x %x %x %x %x\n", &uid, &nt0, &nr0_enc, &ar0_enc, &nt1, &nr1_enc, &ar1_enc); - attack(uid, nt0, nr0_enc, ar0_enc, nt1, nr1_enc, ar1_enc, false); - } - else { - break; - } - } + char line[63]; + while(fgets(line, sizeof(line), stdin)) { + sscanf(line, "%x %x %x %x %x %x %x\n", &uid, &nt0, &nr0_enc, &ar0_enc, &nt1, &nr1_enc, &ar1_enc); + attack(uid, nt0, nr0_enc, ar0_enc, nt1, nr1_enc, ar1_enc, false); + } } else { printf("syntax: %s \n", argv[0]);