Skip to content

Commit

Permalink
cbor_decode_gpio_pins: convert to upper before parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Jul 1, 2024
1 parent 64597a0 commit 7bf0805
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/target.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "core/target.h"

#include <ctype.h>
#include <string.h>

#include "driver/gpio.h"
Expand Down Expand Up @@ -165,14 +166,19 @@ cbor_result_t cbor_encode_gpio_pins_t(cbor_value_t *enc, const gpio_pins_t *t) {
cbor_result_t cbor_decode_gpio_pins_t(cbor_value_t *dec, gpio_pins_t *t) {
cbor_result_t res = CBOR_OK;

const uint8_t *buf;
const uint8_t *tmp;
uint32_t size;
CBOR_CHECK_ERROR(res = cbor_decode_tstr(dec, &buf, &size));
CBOR_CHECK_ERROR(res = cbor_decode_tstr(dec, &tmp, &size));

if (size > 4 && size < 3) {
return CBOR_ERR_INVALID_TYPE;
}

uint8_t buf[size];
for (uint32_t i = 0; i < size; i++) {
buf[i] = toupper(tmp[i]);
}

if (size == 4 && memcmp(buf, pin_none_str, 4) == 0) {
*t = PIN_NONE;
return res;
Expand Down

0 comments on commit 7bf0805

Please sign in to comment.