Improve frame encoding error handling, reporting

Changes:

    * Improve error detection in patty_ax25_frame_encode()

    * Make patty_ax25_frame_encode() set EOVERFLOW when encoding beyond
      the caller specified limit

    * Make patty_ax25_frame_encode_reply_to() set EOVERFLOW when
      encoding beyond the caller specified limit
This commit is contained in:
XANTRONIX Development 2020-09-15 14:18:26 -05:00 committed by XANTRONIX Industrial
parent 30b17d337b
commit bd1238e0bd

View file

@ -476,7 +476,9 @@ ssize_t patty_ax25_frame_encode(patty_ax25_frame *frame,
} }
if (frame->info && frame->infolen) { if (frame->info && frame->infolen) {
if (1 + offset + frame->infolen > len) { if (len < 1 + offset + frame->infolen) {
errno = EOVERFLOW;
goto error_toobig; goto error_toobig;
} }
@ -623,6 +625,8 @@ ssize_t patty_ax25_frame_encode_reply_to(patty_ax25_frame *frame,
if (PATTY_AX25_FRAME_CONTROL_I(reply->control) || PATTY_AX25_FRAME_CONTROL_UI(reply->control)) { if (PATTY_AX25_FRAME_CONTROL_I(reply->control) || PATTY_AX25_FRAME_CONTROL_UI(reply->control)) {
if (len < 1 + offset + reply->infolen) { if (len < 1 + offset + reply->infolen) {
errno = EOVERFLOW;
goto error_toobig; goto error_toobig;
} }