OSS-Fuzz: Fix gtp-message-fuzz to accommodate both v1 and v2
Some checks are pending
CIFuzz / Fuzzing (push) Waiting to run
Meson Continuous Integration / Build and Test on Ubuntu Latest (push) Waiting to run

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
This commit is contained in:
Arthur Chan 2026-08-20 19:20:22 +01:00 • committed by Sukchan Lee
parent 8d7dc80079
commit 7b7327aa61
2 changed files with 12 additions and 2 deletions

View file

@ -25,6 +25,7 @@
#define kMinInputLength 5
#define kMaxInputLength 1024
#define GTP_VERSION(byte) (((byte) >> 5) & 0x07)
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{ /* open5gs/tests/non3gpp/gtp-path.c */
@ -47,8 +48,17 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
}
ogs_pkbuf_put_data(pkbuf, Data, Size);
ogs_gtp2_message_t gtp_message;
ogs_gtp2_parse_msg(&gtp_message, pkbuf);
if (GTP_VERSION(Data[0]) == OGS_GTP1_VERSION_1) {
/* GTPv1 */
if (Size >= 8) {
ogs_gtp1_message_t gtp1_message;
ogs_gtp1_parse_msg(&gtp1_message, pkbuf);
}
} else {
/* GTPv2 */
ogs_gtp2_message_t gtp_message;
ogs_gtp2_parse_msg(&gtp_message, pkbuf);
}
ogs_pkbuf_free(pkbuf);