argus_utils.c segfaults on ICMPv6 Type 2: Packet To Big
The main issue is using strlen on a NULL string in ArgusPrintState
int slen = strlen(ArgusProcessStr);
The reason there is a NULL string in the first place is caused by ArgusGetICMPv6Status
case ICMP6_PACKET_TOO_BIG:
retn = icmptypestr[45];
break;
icmptypestr is declared in argus_util.h as
#define ICMP_MAXTYPE 46
char *icmptypestr[ICMP_MAXTYPE + 1] = {
"ECR", " ", " ", "UR" , "SRC", "RED",
"AHA", " ", "ECO", "RTA", "RTS", "TXD",
"PAR", "TST", "TSR", "IRQ", "IRR", "MAS",
"MSR", "SEC", "ROB", "ROB", "ROB", "ROB",
"ROB", "ROB", "ROB", "ROB", "ROB", "ROB",
"TRC", "DCE", "MHR", "WAY", "IAH", "MRQ",
"MRP", "DNQ", "DNP", "SKP", "PHO", "EXM",
"EEO", "EER",
};
Counting the string elements we can see there are only 44 even though the array is defined to be 47 elements
so retn = icmptypestr[45]; will assign a null string to retn.
Here is a proposed patch
argus_util.c
diff --git a/common/argus_util.c b/common/argus_util.c
index ca0e4fc..8b4e6df 100644
--- a/common/argus_util.c
+++ b/common/argus_util.c
@@ -19716,7 +19716,10 @@ ArgusPrintState (struct ArgusParserStruct *parser, char *buf, struct ArgusRecord
sprintf (buf, " State = \"%s\"", ArgusProcessStr);
} else {
- int slen = strlen(ArgusProcessStr);
+ int slen = 0;
+ if (ArgusProcessStr != NULL) {
+ int slen = strlen(ArgusProcessStr);
+ }
if (parser->RaFieldWidth != RA_FIXED_WIDTH) {
len = slen;
} else {
@@ -26586,7 +26589,7 @@ ArgusGetICMPv6Status (struct ArgusParserStruct *parser, struct ArgusRecordStruct
}
break;
case ICMP6_PACKET_TOO_BIG:
- retn = icmptypestr[45];
+ retn = "PTB";
break;
case ICMP6_TIME_EXCEEDED:
switch (icmp->code) {
argus_util.h
diff --git a/include/argus_util.h b/include/argus_util.h
index 12b22ce..2d7c4c5 100644
--- a/include/argus_util.h
+++ b/include/argus_util.h
@@ -1570,7 +1570,7 @@ char *icmptypestr[ICMP_MAXTYPE + 1] = {
"ROB", "ROB", "ROB", "ROB", "ROB", "ROB",
"TRC", "DCE", "MHR", "WAY", "IAH", "MRQ",
"MRP", "DNQ", "DNP", "SKP", "PHO", "EXM",
- "EEO", "EER",
+ "EEO", "EER", " ", " ", " ",
};
argus_utils.c segfaults on ICMPv6 Type 2: Packet To Big
The main issue is using strlen on a NULL string in ArgusPrintState
The reason there is a NULL string in the first place is caused by ArgusGetICMPv6Status
icmptypestr is declared in argus_util.h as
Counting the string elements we can see there are only 44 even though the array is defined to be 47 elements
so
retn = icmptypestr[45];will assign a null string to retn.Here is a proposed patch
argus_util.c
argus_util.h