diff options
author | Donald Sharp <sharpd@nvidia.com> | 2021-08-04 17:13:26 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2021-08-04 17:13:26 +0200 |
commit | 1ae0e1b315edf256d41760bcbb631b5d2be0d087 (patch) | |
tree | f413a57b862f429e2f02eca301c95f4706c84710 /lib/zclient.c | |
parent | Merge pull request #8182 from mjstapp/topotest_start_tgen (diff) | |
download | frr-1ae0e1b315edf256d41760bcbb631b5d2be0d087.tar.xz frr-1ae0e1b315edf256d41760bcbb631b5d2be0d087.zip |
lib: Convert assert to error and record it instead of aborting
When we get a bad value for the opaque data length, instead
of stopping the program, discard the data and move on.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to '')
-rw-r--r-- | lib/zclient.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 0815e77d4..f68e0e1b0 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1299,7 +1299,13 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) stream_putl(s, api->tableid); if (CHECK_FLAG(api->message, ZAPI_MESSAGE_OPAQUE)) { - assert(api->opaque.length <= ZAPI_MESSAGE_OPAQUE_LENGTH); + if (api->opaque.length > ZAPI_MESSAGE_OPAQUE_LENGTH) { + flog_err( + EC_LIB_ZAPI_ENCODE, + "%s: opaque length %u is greater than allowed value", + __func__, api->opaque.length); + return -1; + } stream_putw(s, api->opaque.length); stream_write(s, api->opaque.data, api->opaque.length); @@ -1537,7 +1543,13 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) if (CHECK_FLAG(api->message, ZAPI_MESSAGE_OPAQUE)) { STREAM_GETW(s, api->opaque.length); - assert(api->opaque.length <= ZAPI_MESSAGE_OPAQUE_LENGTH); + if (api->opaque.length > ZAPI_MESSAGE_OPAQUE_LENGTH) { + flog_err( + EC_LIB_ZAPI_ENCODE, + "%s: opaque length %u is greater than allowed value", + __func__, api->opaque.length); + return -1; + } STREAM_GET(api->opaque.data, s, api->opaque.length); } |