diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2024-03-19 15:11:39 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2024-04-16 16:49:46 +0300 |
commit | ade28e540aca1dcee8ca95aaf546c0b014364732 (patch) | |
tree | e6bf76d3c74ce850f3d8bad62193d238bec4ba08 | |
parent | 948f53cb9255d3227f40422e72e276a1c43781b8 (diff) |
validation: crypto: in write_header_and_trailer(), return immediately if header and trailer lengths are zero
If write_header_and_trailer() is called with both header_len and
trailer_len zero, the buffer[] array ends up being zero size, which is
undefined behavior. Fix by returning early in that case.
Fixes GCC undefined sanitizer error:
crypto_op_test.c:165:10: runtime error: variable length array bound evaluates to non-positive value 0
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
-rw-r--r-- | test/validation/api/crypto/crypto_op_test.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/validation/api/crypto/crypto_op_test.c b/test/validation/api/crypto/crypto_op_test.c index b60052d7c..f2703c5cc 100644 --- a/test/validation/api/crypto/crypto_op_test.c +++ b/test/validation/api/crypto/crypto_op_test.c @@ -162,6 +162,10 @@ static void write_header_and_trailer(odp_packet_t pkt, { uint32_t trailer_offset = odp_packet_len(pkt) - trailer_len; uint32_t max_len = header_len > trailer_len ? header_len : trailer_len; + + if (!max_len) + return; + uint8_t buffer[max_len]; int rc; |