From 9b4564d7f304a2cf3c9ce66cdcba9594aa040006 Mon Sep 17 00:00:00 2001 From: Freddie Chopin Date: Mon, 3 Feb 2014 12:36:03 +0100 Subject: [PATCH] snmp_trap_header_sum(): use strlen() to get the length of community string Signed-off-by: Freddie Chopin --- src/core/snmp/msg_out.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/snmp/msg_out.c b/src/core/snmp/msg_out.c index ecc524c5..e9baef49 100644 --- a/src/core/snmp/msg_out.c +++ b/src/core/snmp/msg_out.c @@ -52,6 +52,8 @@ #include "lwip/snmp_asn1.h" #include "lwip/snmp_msg.h" +#include + struct snmp_trap_dst { /* destination IP address in network order */ @@ -398,7 +400,7 @@ snmp_trap_header_sum(struct snmp_msg_trap *m_trap, u16_t vb_len) snmp_asn1_enc_length_cnt(thl->pdulen, &thl->pdulenlen); tot_len += 1 + thl->pdulenlen; - thl->comlen = sizeof(snmp_publiccommunity) - 1; + thl->comlen = strlen(snmp_publiccommunity); snmp_asn1_enc_length_cnt(thl->comlen, &thl->comlenlen); tot_len += 1 + thl->comlenlen + thl->comlen;