mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
fix (NAS UE): decode FGC NAS container length as 16-bit IE
Decode the FGC NAS message container length from the encoded 2-octet field before validating and copying the payload. This matches TS 24.501, where the NAS message container is a type 6 TLV and its length is carried in octets 2-3. Changes: - add `<arpa/inet.h>` for `ntohs` - change `ielen` from `uint8_t` to `uint16_t` in `decode_fgc_nas_message_container()` - read the encoded length with `memcpy`, convert it from network byte order, and advance the decode pointer by `sizeof(uint16_t)` Refs: - TS 124 501 clause 9.11.3.33 "NAS message container" Signed-off-by: Guido Casati <guido.casati@openairinterface.org>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
@@ -17,7 +18,7 @@
|
||||
int decode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
uint8_t ielen = 0;
|
||||
uint16_t ielen = 0;
|
||||
int decode_result;
|
||||
|
||||
if (iei > 0) {
|
||||
@@ -25,8 +26,10 @@ int decode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer
|
||||
decoded++;
|
||||
}
|
||||
|
||||
ielen = *(buffer + decoded);
|
||||
decoded += 2;
|
||||
uint16_t encoded_ielen;
|
||||
memcpy(&encoded_ielen, buffer + decoded, sizeof(encoded_ielen));
|
||||
ielen = ntohs(encoded_ielen);
|
||||
decoded += sizeof(encoded_ielen);
|
||||
CHECK_LENGTH_DECODER(len - decoded, ielen);
|
||||
|
||||
if ((decode_result =
|
||||
@@ -38,6 +41,7 @@ int decode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
int encode_fgc_nas_message_container(const FGCNasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
|
||||
Reference in New Issue
Block a user