mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-03 05:23:38 +00:00
[SEC] Fix PFCP Message Length Validation in ogs_pfcp_recvfrom (#3689)
This commit modifies the message length check in ogs_pfcp_recvfrom. Previously, the condition only verified that the received size was less than the expected length, which could allow messages that are too long to be processed. The condition now requires an exact match between the received size and the expected total PFCP message length, ensuring proper message validation.
This commit is contained in:
@@ -111,8 +111,8 @@ ogs_pkbuf_t *ogs_pfcp_recvfrom(ogs_socket_t fd, ogs_sockaddr_t *from)
|
||||
excluding the first 4 bytes. */
|
||||
pfcp_body_length = be16toh(h->length);
|
||||
expected_total_length = pfcp_body_length + 4;
|
||||
if ((size_t)size < expected_total_length) {
|
||||
ogs_error("Incomplete PFCP message: expected %zu bytes, "
|
||||
if ((size_t)size != expected_total_length) {
|
||||
ogs_error("Invalid PFCP Header Length: expected %zu bytes, "
|
||||
"received %ld bytes", expected_total_length, size);
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user