From 591b246ed69006b20a27fd08b405ea29943b6ed0 Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 9 Nov 2024 23:33:33 +0300 Subject: [PATCH] mdig: fix text mode std io in windows --- mdig/mdig.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mdig/mdig.c b/mdig/mdig.c index d50c1cc..6521f5f 100644 --- a/mdig/mdig.c +++ b/mdig/mdig.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #ifdef _WIN32 @@ -21,7 +20,9 @@ #include #include #include +#include #else +#include #include #include #include @@ -364,6 +365,9 @@ int dns_make_query(const char *dom, char family) fprintf(stderr, "could not make DNS query\n"); return 1; } +#ifdef _WIN32 + _setmode(_fileno(stdout), _O_BINARY); +#endif if (fwrite(q,l,1,stdout)!=1) { fprintf(stderr, "could not write DNS query blob to stdout\n"); @@ -422,6 +426,9 @@ int dns_parse_query() { uint8_t a[1500]; size_t l; +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); +#endif l = fread(a,1,sizeof(a),stdin); if (!l || !feof(stdin)) {