Skip to content

Commit 571cca2

Browse files
authored
Merge pull request FRRouting#16718 from louis-6wind/fix-asla-length
isisd: fix crash when reading asla
2 parents 2b4a262 + f1bc6c5 commit 571cca2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

isisd/isis_tlvs.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -1914,8 +1914,8 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len,
19141914
uint8_t sabm_flag_len;
19151915
/* User-defined App Identifier Bit Flags/Length */
19161916
uint8_t uabm_flag_len;
1917-
uint8_t sabm[ASLA_APP_IDENTIFIER_BIT_LENGTH] = {0};
1918-
uint8_t uabm[ASLA_APP_IDENTIFIER_BIT_LENGTH] = {0};
1917+
uint8_t sabm[ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH] = { 0 };
1918+
uint8_t uabm[ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH] = { 0 };
19191919
uint8_t readable = subtlv_len;
19201920
uint8_t subsubtlv_type;
19211921
uint8_t subsubtlv_len;
@@ -1946,6 +1946,15 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len,
19461946
return -1;
19471947
}
19481948

1949+
if ((asla->standard_apps_length > ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH) ||
1950+
(asla->user_def_apps_length > ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH)) {
1951+
zlog_err("Standard or User-Defined Application Identifier Bit Mask Length greater than %u bytes. Received respectively a length of %u and %u bytes.",
1952+
ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH,
1953+
asla->standard_apps_length, asla->user_def_apps_length);
1954+
stream_forward_getp(s, readable);
1955+
return -1;
1956+
}
1957+
19491958
for (int i = 0; i < asla->standard_apps_length; i++)
19501959
sabm[i] = stream_getc(s);
19511960
for (int i = 0; i < asla->user_def_apps_length; i++)

isisd/isis_tlvs.h

+1
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ struct isis_ext_subtlvs {
717717
#define ISIS_SABM_FLAG_X 0x10 /* Flex-Algorithm - RFC9350 */
718718

719719
#define ASLA_APP_IDENTIFIER_BIT_LENGTH 1
720+
#define ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH 8
720721
#define ASLA_LEGACY_FLAG 0x80
721722
#define ASLA_APPS_LENGTH_MASK 0x7f
722723

0 commit comments

Comments
 (0)