snmp_v3: use strlen, not strnlen

strnlen is not portable.
In this case, it does not matter as we zero-terminate the string before.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
Simon Goldschmidt 2018-11-19 20:13:30 +01:00
parent 4413576494
commit 3bd84aba4b

View File

@ -834,7 +834,7 @@ snmp_parse_inbound_frame(struct snmp_request *request)
/* @todo: Differentiate read/write access */
strncpy((char *)request->community, snmp_community, SNMP_MAX_COMMUNITY_STR_LEN);
request->community[SNMP_MAX_COMMUNITY_STR_LEN] = 0; /* ensure NULL termination (strncpy does NOT guarantee it!) */
request->community_strlen = (u16_t)strnlen((char *)request->community, SNMP_MAX_COMMUNITY_STR_LEN);
request->community_strlen = (u16_t)strlen((char *)request->community);
/* RFC3414 globalData */
IF_PARSE_EXEC(snmp_asn1_dec_tlv(&pbuf_stream, &tlv));