mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
SNMP. Fix several ignored return values
This commit is contained in:
parent
2673e635a3
commit
132c285fd4
@ -1672,7 +1672,7 @@ snmp_complete_outbound_frame(struct snmp_request *request)
|
|||||||
struct snmp_pbuf_stream inbound_stream;
|
struct snmp_pbuf_stream inbound_stream;
|
||||||
OF_BUILD_EXEC( snmp_pbuf_stream_init(&inbound_stream, request->inbound_pbuf, request->inbound_varbind_offset, request->inbound_varbind_len) );
|
OF_BUILD_EXEC( snmp_pbuf_stream_init(&inbound_stream, request->inbound_pbuf, request->inbound_varbind_offset, request->inbound_varbind_len) );
|
||||||
OF_BUILD_EXEC( snmp_pbuf_stream_init(&(request->outbound_pbuf_stream), request->outbound_pbuf, request->outbound_varbind_offset, request->outbound_pbuf->tot_len - request->outbound_varbind_offset) );
|
OF_BUILD_EXEC( snmp_pbuf_stream_init(&(request->outbound_pbuf_stream), request->outbound_pbuf, request->outbound_varbind_offset, request->outbound_pbuf->tot_len - request->outbound_varbind_offset) );
|
||||||
snmp_pbuf_stream_writeto(&inbound_stream, &(request->outbound_pbuf_stream), 0);
|
OF_BUILD_EXEC( snmp_pbuf_stream_writeto(&inbound_stream, &(request->outbound_pbuf_stream), 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_size = request->outbound_pbuf_stream.offset;
|
frame_size = request->outbound_pbuf_stream.offset;
|
||||||
@ -1683,7 +1683,7 @@ snmp_complete_outbound_frame(struct snmp_request *request)
|
|||||||
u8_t i;
|
u8_t i;
|
||||||
outbound_padding = (8 - (u8_t)((frame_size - request->outbound_scoped_pdu_seq_offset) & 0x07)) & 0x07;
|
outbound_padding = (8 - (u8_t)((frame_size - request->outbound_scoped_pdu_seq_offset) & 0x07)) & 0x07;
|
||||||
for (i = 0; i < outbound_padding; i++) {
|
for (i = 0; i < outbound_padding; i++) {
|
||||||
snmp_pbuf_stream_write(&request->outbound_pbuf_stream, 0);
|
OF_BUILD_EXEC( snmp_pbuf_stream_write(&request->outbound_pbuf_stream, 0) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -154,29 +154,36 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length,
|
|||||||
out_len = LWIP_ARRAYSIZE(out_bytes) ;
|
out_len = LWIP_ARRAYSIZE(out_bytes) ;
|
||||||
|
|
||||||
for (j = 0; j < LWIP_ARRAYSIZE(in_bytes); j++) {
|
for (j = 0; j < LWIP_ARRAYSIZE(in_bytes); j++) {
|
||||||
snmp_pbuf_stream_read(&read_stream, &in_bytes[j]);
|
if (snmp_pbuf_stream_read(&read_stream, &in_bytes[j]) != ERR_OK) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mbedtls_cipher_update(&ctx, in_bytes, LWIP_ARRAYSIZE(in_bytes), out_bytes, &out_len) != 0) {
|
if (mbedtls_cipher_update(&ctx, in_bytes, LWIP_ARRAYSIZE(in_bytes), out_bytes, &out_len) != 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
snmp_pbuf_stream_writebuf(&write_stream, out_bytes, (u16_t)out_len);
|
if (snmp_pbuf_stream_writebuf(&write_stream, out_bytes, (u16_t)out_len) != ERR_OK) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out_len = LWIP_ARRAYSIZE(out_bytes);
|
out_len = LWIP_ARRAYSIZE(out_bytes);
|
||||||
if(mbedtls_cipher_finish(&ctx, out_bytes, &out_len) != 0) {
|
if (mbedtls_cipher_finish(&ctx, out_bytes, &out_len) != 0) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snmp_pbuf_stream_writebuf(&write_stream, out_bytes, (u16_t)out_len) != ERR_OK) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
snmp_pbuf_stream_writebuf(&write_stream, out_bytes, (u16_t)out_len);
|
|
||||||
} else if (algo == SNMP_V3_PRIV_ALGO_AES) {
|
} else if (algo == SNMP_V3_PRIV_ALGO_AES) {
|
||||||
u8_t iv_local[16];
|
u8_t iv_local[16];
|
||||||
|
|
||||||
cipher_info = mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_CFB128);
|
cipher_info = mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_CFB128);
|
||||||
if(mbedtls_cipher_setup(&ctx, cipher_info) != 0) {
|
if (mbedtls_cipher_setup(&ctx, cipher_info) != 0) {
|
||||||
return ERR_ARG;
|
return ERR_ARG;
|
||||||
}
|
}
|
||||||
if(mbedtls_cipher_setkey(&ctx, key, 16*8, (mode == SNMP_V3_PRIV_MODE_ENCRYPT)? MBEDTLS_ENCRYPT : MBEDTLS_DECRYPT) != 0) {
|
if (mbedtls_cipher_setkey(&ctx, key, 16*8, (mode == SNMP_V3_PRIV_MODE_ENCRYPT)? MBEDTLS_ENCRYPT : MBEDTLS_DECRYPT) != 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,11 +209,15 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length,
|
|||||||
u8_t out_byte;
|
u8_t out_byte;
|
||||||
size_t out_len = sizeof(out_byte);
|
size_t out_len = sizeof(out_byte);
|
||||||
|
|
||||||
snmp_pbuf_stream_read(&read_stream, &in_byte);
|
if (snmp_pbuf_stream_read(&read_stream, &in_byte) != ERR_OK) {
|
||||||
if(mbedtls_cipher_update(&ctx, &in_byte, sizeof(in_byte), &out_byte, &out_len) != 0) {
|
goto error;
|
||||||
|
}
|
||||||
|
if (mbedtls_cipher_update(&ctx, &in_byte, sizeof(in_byte), &out_byte, &out_len) != 0) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (snmp_pbuf_stream_write(&write_stream, out_byte) != ERR_OK) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
snmp_pbuf_stream_write(&write_stream, out_byte);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ERR_ARG;
|
return ERR_ARG;
|
||||||
|
Loading…
Reference in New Issue
Block a user