Commit 75cd6915 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix issue for decoding MSIN with an odd number of digits

parent eaed3191
......@@ -1903,6 +1903,7 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
try {
ConfirmationDataResponse confirmationdataresponse;
response.get_to(confirmationdataresponse);
if (!confirmationdataresponse.kseafIsSet()) return false;
unsigned char* kseaf_hex =
conv::format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc->_5g_av[0].kseaf, kseaf_hex, 32);
......
......@@ -373,7 +373,7 @@ int _5GSMobileIdentity::DecodeSuci(uint8_t* buf, int len, int ie_len) {
uint8_t digit_low = 0;
uint8_t digit_high = 0;
int numMsin = ie_len - decoded_size;
for (int i = 0; i < numMsin; i++) {
for (int i = 0; i < (numMsin - 1); i++) {
DECODE_U8(buf + decoded_size, octet, decoded_size);
digit_high = (octet & 0xf0) >> 4;
digit_low = octet & 0x0f;
......@@ -381,6 +381,20 @@ int _5GSMobileIdentity::DecodeSuci(uint8_t* buf, int len, int ie_len) {
((const std::string)(std::to_string(digit_low)) +
(const std::string)(std::to_string(digit_high)));
}
// Verify if the MSIN includes an odd number of digits,
// bits 5 to 8 of the last octet shall be coded as "1111"
DECODE_U8(buf + decoded_size, octet, decoded_size);
digit_high = (octet & 0xf0) >> 4;
digit_low = octet & 0x0f;
if (digit_high != 0x0f) {
msin +=
((const std::string)(std::to_string(digit_low)) +
(const std::string)(std::to_string(digit_high)));
} else {
msin += (const std::string)(std::to_string(digit_low));
}
supi_format_imsi_tmp.msin = msin;
Logger::nas_mm().debug(
"Decoded MSIN %s", supi_format_imsi_tmp.msin.c_str());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment