fixed bug #43790: Sending octet string of Length >255 from SNMP agent (patch by Manoj Kumar)

This commit is contained in:
goldsimon 2015-08-20 08:12:50 +02:00
parent 05abfc8ded
commit 2b93ef1d75
3 changed files with 12 additions and 13 deletions

View File

@ -249,6 +249,10 @@ HISTORY
++ Bugfixes:
2015-08-20: Manoj Kumar
* snmp_msg.h, msg_in.c: fixed bug #43790: Sending octet string of Length >255
from SNMP agent
2015-08-19: Jens Nielsen
* icmp.c, ip4.c, tcp_in.c, udp.c, raw.c: fixed bug #45120: Broadcast & multiple
interfaces handling

View File

@ -293,8 +293,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
msg_ps->vb_ptr->ident_len = 0;
vb->value_type = msg_ps->ext_object_def.asn_type;
LWIP_ASSERT("invalid length", msg_ps->ext_object_def.v_len <= 0xff);
vb->value_len = (u8_t)msg_ps->ext_object_def.v_len;
vb->value_len = msg_ps->ext_object_def.v_len;
if (vb->value_len > 0)
{
LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE);
@ -405,8 +404,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
msg_ps->vb_ptr->ident_len = 0;
vb->value_type = object_def.asn_type;
LWIP_ASSERT("invalid length", object_def.v_len <= 0xff);
vb->value_len = (u8_t)object_def.v_len;
vb->value_len = object_def.v_len;
if (vb->value_len > 0)
{
LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low",
@ -505,10 +503,9 @@ snmp_msg_getnext_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
/* get_value() answer */
en = msg_ps->ext_mib_node;
LWIP_ASSERT("invalid length", msg_ps->ext_object_def.v_len <= 0xff);
vb = snmp_varbind_alloc(&msg_ps->ext_oid,
msg_ps->ext_object_def.asn_type,
(u8_t)msg_ps->ext_object_def.v_len);
msg_ps->ext_object_def.v_len);
if (vb != NULL)
{
en->get_value_a(request_id, &msg_ps->ext_object_def, vb->value_len, vb->value);
@ -580,8 +577,7 @@ snmp_msg_getnext_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF;
mn->get_object_def(1, &oid.id[oid.len - 1], &object_def);
LWIP_ASSERT("invalid length", object_def.v_len <= 0xff);
vb = snmp_varbind_alloc(&oid, object_def.asn_type, (u8_t)object_def.v_len);
vb = snmp_varbind_alloc(&oid, object_def.asn_type, object_def.v_len);
if (vb != NULL)
{
msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE;
@ -1318,8 +1314,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
break;
case (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR):
case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_OPAQUE):
LWIP_ASSERT("invalid length", len <= 0xff);
vb = snmp_varbind_alloc(&oid, type, (u8_t)len);
vb = snmp_varbind_alloc(&oid, type, len);
if (vb != NULL)
{
derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, vb->value_len, (u8_t*)vb->value);
@ -1415,7 +1410,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
}
struct snmp_varbind*
snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len)
snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len)
{
struct snmp_varbind *vb;

View File

@ -91,7 +91,7 @@ struct snmp_varbind
/* object value ASN1 type */
u8_t value_type;
/* object value length (in u8_t) */
u8_t value_len;
u16_t value_len;
/* object value */
void *value;
@ -301,7 +301,7 @@ void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable);
void snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst);
/** Varbind-list functions. */
struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len);
struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len);
void snmp_varbind_free(struct snmp_varbind *vb);
void snmp_varbind_list_free(struct snmp_varbind_root *root);
void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb);