AmendHub

Download:

jcs

/

subtext

/

amendments

/

299

session: Move bogus obuflen check here to cover all node types


jcs made amendment 299 about 1 year ago
--- serial.c Mon Nov 7 11:52:42 2022 +++ serial.c Sun Feb 5 09:31:46 2023 @@ -528,14 +528,6 @@ serial_output(struct session *session) if (session->obuflen == 0 || session->ending) return 0; - if (session->obuflen > sizeof(session->obuf)) { - warn("Bogus obuflen %d > %ld", session->obuflen, - sizeof(session->obuf)); - session->ending = true; - session_close(session); - return 0; - } - memset(&serial_write_pbr, 0, sizeof(serial_write_pbr)); serial_write_pbr.ioParam.ioRefNum = serial_out_refnum; serial_write_pbr.ioParam.ioBuffer = (Ptr)&session->obuf; --- session.c Sat Nov 19 23:09:52 2022 +++ session.c Sun Jan 15 21:14:20 2023 @@ -525,9 +525,16 @@ session_output(struct session *session, const char *st } if (chunk > len) chunk = len; - + memcpy(session->obuf + session->obuflen, str + stroff, chunk); session->obuflen += chunk; + if (session->obuflen > sizeof(session->obuf)) { + warn("[%s] Bogus obuflen %d > %ld", session->node, + session->obuflen, sizeof(session->obuf)); + session->ending = true; + session_close(session); + return 0; + } stroff += chunk; len -= chunk; }