mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
examples/nanocoap_server: fix a buffer overflow bug
This commit is contained in:
parent
fed2c8e87e
commit
68ccf36754
@ -97,11 +97,16 @@ static ssize_t _riot_value_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, vo
|
||||
case COAP_PUT:
|
||||
case COAP_POST:
|
||||
{
|
||||
/* convert the payload to an integer and update the internal value */
|
||||
char payload[16] = { 0 };
|
||||
memcpy(payload, (char*)pkt->payload, pkt->payload_len);
|
||||
internal_value = strtol(payload, NULL, 10);
|
||||
code = COAP_CODE_CHANGED;
|
||||
if (pkt->payload_len < 16) {
|
||||
/* convert the payload to an integer and update the internal value */
|
||||
char payload[16] = { 0 };
|
||||
memcpy(payload, (char*)pkt->payload, pkt->payload_len);
|
||||
internal_value = strtol(payload, NULL, 10);
|
||||
code = COAP_CODE_CHANGED;
|
||||
}
|
||||
else {
|
||||
code = COAP_CODE_REQUEST_ENTITY_TOO_LARGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user