/*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
snmplib_debug(4, "snmp_msg_Decode:Error decoding SNMP Message Header (Version)!\n");
ASN_PARSE_ERROR(NULL);
}
+ int terminatorPos = *CommLenP - 1;
bufp = asn_parse_string(bufp, PacketLenP, &type, Community, CommLenP);
if (bufp == NULL) {
snmplib_debug(4, "snmp_msg_Decode:Error decoding SNMP Message Header (Community)!\n");
ASN_PARSE_ERROR(NULL);
}
- Community[*CommLenP] = '\0';
+ if (*CommLenP < terminatorPos) {
+ terminatorPos = *CommLenP;
+ }
+ Community[terminatorPos] = '\0';
if ((*Version != SNMP_VERSION_1) &&
(*Version != SNMP_VERSION_2)) {