Skip to content

Commit 80ed815

Browse files
committed
Update to latest library
Internal build #123 (6aa401a1c9c) Signed-off-by: Håvard Vermeer <havard.vermeer@nordicsemi.no>
1 parent 955f73d commit 80ed815

File tree

7 files changed

+8
-18
lines changed

7 files changed

+8
-18
lines changed

lib/bin/sb_fota/include/sb_fota_settings.h

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#ifndef SB_FOTA_SETTINGS_H
1515
#define SB_FOTA_SETTINGS_H
1616

17+
#define SB_FOTA_CLIENT_ID_LEN (NRF_DEVICE_UUID_STR_LEN + sizeof(CONFIG_SB_FOTA_ID_PREFIX))
18+
1719
/**
1820
* @brief Get sec_tag for cloud TLS communication.
1921
*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

lib/bin/sb_fota/os/sb_fota_os.c

+5-17
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,19 @@ static const struct sb_fota_settings *sb_fota_settings;
258258
static int settings_set(const char *name, size_t len,
259259
settings_read_cb read_cb, void *cb_arg)
260260
{
261-
void *data;
262-
263261
for (const struct sb_fota_settings *sp = sb_fota_settings; sp->name; ++sp) {
264262
if (strcmp(name, sp->name)) {
265263
continue;
266264
}
267-
/* Do I need to allocate the storage? */
268-
if (sp->len > 0) {
269-
data = sp->ptr;
270-
} else {
271-
data = sb_fota_os_malloc(len);
272-
*((void**)sp->ptr) = data;
273-
if (data == NULL) {
274-
return -ENOMEM;
275-
}
265+
266+
if (len > sp->len) {
267+
LOG_ERR("Failed loading \"%s\" from settings, value too long", name);
268+
return -EINVAL;
276269
}
277270

278-
if (read_cb(cb_arg, data, len) > 0) {
271+
if (read_cb(cb_arg, sp->ptr, len) > 0) {
279272
return 0;
280273
} else {
281-
/* if this was allocated, free it */
282-
if (sp->len == 0) {
283-
sb_fota_os_free(data);
284-
*((void**)sp->ptr) = NULL;
285-
}
286274
return -EINVAL;
287275
}
288276
}

lib/bin/sb_fota/os/sb_fota_settings.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int sb_fota_settings_jwt_sec_tag_get(void)
2828
return CONFIG_SB_FOTA_JWT_SECURITY_TAG;
2929
}
3030

31-
static char sb_fota_client_id[NRF_DEVICE_UUID_STR_LEN + sizeof(CONFIG_SB_FOTA_ID_PREFIX)];
31+
static char sb_fota_client_id[SB_FOTA_CLIENT_ID_LEN];
3232

3333
static int get_uuid(void)
3434
{

0 commit comments

Comments
 (0)