Closed shellwayxw closed 8 months ago
I checked the code and the root cause is that in ogs_gtpu_parse_header, variable i in line 66 is not checked. Adding i < OGS_GTP2_NUM_OF_EXTENSION_HEADER to the while loop (line 67) should resolve this problem.
@shellwayxw
Could you please retest the modified code as shown below?
$ diff --git a/lib/gtp/util.c b/lib/gtp/util.c
index 3ec27d577..cb6b6e064 100644
--- a/lib/gtp/util.c
+++ b/lib/gtp/util.c
@@ -65,7 +65,8 @@ int ogs_gtpu_parse_header(
* then the value of the Next Extension Header Type shall be 0. */
i = 0;
- while (*(ext_h = (((uint8_t *)gtp_h) + len - 1))) {
+ while (*(ext_h = (((uint8_t *)gtp_h) + len - 1)) &&
+ i < OGS_GTP2_NUM_OF_EXTENSION_HEADER) {
/*
* The length of the Extension header shall be defined
* in a variable length of 4 octets, i.e. m+1 = n*4 octets,
Thanks a lot! Sukchan
Sure. I applied the patch and retested the program. It did not abort again. Thanks for the fix.
@shellwayxw
I've fixed this issue and pushed it to the main branch.
Please let me know if you have any other issues.
Thanks a lot! Sukchan
Open5GS Release, Revision, or Tag
v2.7.0
Steps to reproduce
poc: sendto.txt
Logs
Expected behaviour
The program should detect the overflow and not abort.
Observed Behaviour
With the stack canary in the compiler option, the program aborts.
eNodeB/gNodeB
No response
UE Models and versions
No response