Subj : Blocking
To   : Dallas Hinton
From : andrew clarke
Date : Fri Nov 12 2021 03:37 pm

On 2021-11-11 16:19:30, Dallas Hinton (1:153/7715) wrote to all:

DH> Binkd on Windows 10 32-bit. Is there a way to block a particular node
DH> from doing a file request? I've one node who keeps requesting a packet
DH> (that doesn't exist) and that causes Binkd to crash! :-(

DH> + 11 Nov 15:20:41 [1980] pwd protected session (MD5)
DH> + 11 Nov 15:20:41 [1980] sending c:\OUTBOUND\000f1d91.th0 as
DH> 000f1d91.th0 (165816) - 11 Nov 15:20:41 [1980] receiving 61e1ed3d.pkt
DH> (186 byte(s), off 0) ? 11 Nov 15:20:41 [1980] GET: remote requests
DH> seeking 000f1d91.th0 to 180224, file size I64u

I suspect turning off logging temporarily will prevent the crash.

...

I don't have time to send a pull request, but for other developers reading this:

"I64u" is a printf-formatting bug. It should be "%I64u", which gets converted to the file size at runtime.

diff for protocol.c:

-        Log (1, "GET: remote requests seeking %s to %" PRIuMAX ", file size " PRIuMAX,
+        Log (1, "GET: remote requests seeking %s to %" PRIuMAX ", file size %" PRIuMAX,
             argv[0], (uintmax_t) offset, (uintmax_t) state->out.size);
-        msg_sendf(state, M_ERR, "Invalid M_GET violates binkp: offset " PRIuMAX " after end of file, file %s size " PRIuMAX,
+        msg_sendf(state, M_ERR, "Invalid M_GET violates binkp: offset %" PRIuMAX " after end of file, file %s size %" PRIuMAX,

Though this isn't the only place in the binkd code where this bug exists.

Obviously checking whether PRIuMAX is prefixed with "%" in every call to Log() or msg_sendf() etc is visually difficult and error-prone.

This should instead be fixed at the source, in sys.h:

-  #define PRIdMAX "I64i"
-  #define PRIuMAX "I64u"
+  #define PRIdMAX "%I64i"
+  #define PRIuMAX "%I64u"

Then change the .c files that reference these macros accordingly.

--- GoldED+/BSD 1.1.5-b20180707
* Origin: Blizzard of Ozz, Melbourne, Victoria, Australia (3:633/267)