diff --git a/easyflash/inc/ef_cfg.h b/easyflash/inc/ef_cfg.h index c28e0e2..637571b 100644 --- a/easyflash/inc/ef_cfg.h +++ b/easyflash/inc/ef_cfg.h @@ -79,7 +79,7 @@ /* backup area start address */ #define EF_START_ADDR /* @note you must define it for a value */ -/* ENV area size. It's at least one empty sector for GC. So it's definination must more then or equal 2 flash sector size. */ +/* ENV area size. It's at least one empty sector for GC. So it's definition must more then or equal 2 flash sector size. */ #define ENV_AREA_SIZE /* @note you must define it for a value if you used ENV */ /* saved log area size */ diff --git a/easyflash/src/ef_env.c b/easyflash/src/ef_env.c index 61d786d..1d3681f 100644 --- a/easyflash/src/ef_env.c +++ b/easyflash/src/ef_env.c @@ -580,12 +580,13 @@ size_t ef_get_env_blob(const char *key, void *value_buf, size_t buf_len, size_t */ char *ef_get_env(const char *key) { - static char value[EF_STR_ENV_VALUE_MAX_SIZE]; + static char value[EF_STR_ENV_VALUE_MAX_SIZE + 1]; size_t get_size; - if ((get_size = ef_get_env_blob(key, value, sizeof(value), NULL)) > 0) { + if ((get_size = ef_get_env_blob(key, value, EF_STR_ENV_VALUE_MAX_SIZE, NULL)) > 0) { /* the return value must be string */ if (ef_is_str((uint8_t *)value, get_size)) { + value[get_size] = '\0'; return value; } else { EF_INFO("Warning: The ENV value isn't string. Could not be returned\n");