Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit 03f83cb

Browse files
committed
tell nvs_get_str() the buffer-length; lower buffer size to 256 bytes
On nvs_get_str() the length should be initialized with the size of the buffer. Also lowered the size of the buffer. We should not store very large strings in NVS, and we do not have that much space on the stack. If we really need such large strings, we should use malloc or a static buffer for reading the large string.
1 parent 00df83d commit 03f83cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

esp32/modbadge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ STATIC mp_obj_t badge_nvs_get_str_(mp_uint_t n_args, const mp_obj_t *args) {
4848
mp_uint_t len;
4949
const char *namespace = mp_obj_str_get_data(args[0], &len);
5050
const char *key = mp_obj_str_get_data(args[1], &len);
51-
char value[1024]; // TODO wut?
52-
size_t length;
51+
char value[256]; // TODO wut?
52+
size_t length = sizeof(value);
5353
esp_err_t err = badge_nvs_get_str(namespace, key, value, &length);
5454
if (err != ESP_OK) {
5555
if (n_args > 2) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy