Skip to contentSkip to conversation

settings: Overwrite values before freeing memory

PATCH Applied Andrew Zaborowski 3 participants 4 messages Apr 28, 2018 – Apr 30, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 settings: Overwrite values before freeing memory

Since there may be sensitive data in the setting values, wipe the value memory before freeing.

---
 ell/settings.c | 1 +
 1 file changed, 1 insertion(+)
ell/settings.c +1 -0
index a556144..8e67fa3 100644
@@ -61,6 +61,7 @@ static void setting_destroy(void *data)
 	struct setting_data *pair = data;
 
 	l_free(pair->key);
+	memset(pair->value, 0, strlen(pair->value));
 	l_free(pair->value);
 	l_free(pair);
 }
Signature · 1 line
2.14.1
#1 lore raw

Hi Andrew,

Quoted 6 lines · Andrew Zaborowski

Since there may be sensitive data in the setting values, wipe the value memory before freeing.

---
  ell/settings.c | 1 +
  1 file changed, 1 insertion(+)

Applied, thanks.

Regards,
-Denis

#2 lore raw
In reply to Andrew Zaborowski
Quoted 11 lines · Andrew Zaborowski

Since there may be sensitive data in the setting values, wipe the value memory before freeing.
---
ell/settings.c | 1 +

1 file changed, 1 insertion(+)
ell/settings.c +0 -0
index a556144..8e67fa3 100644

ell/settings.c static void setting_destroy(void *data) · line 64

Quoted 4 lines
ell/settings.c +1 -0
@@ -61,6 +61,7 @@ static void setting_destroy(void *data)
 	struct setting_data *pair = data;
 
 	l_free(pair->key);
+	memset(pair->value, 0, strlen(pair->value));

l_free can handle pair->value == NULL, but strlen and memset can't. Is it worth checking for that?

Quoted 11 lines
ell/settings.c +0 -0
 	l_free(pair->value);
 	l_free(pair);
 }
Signature · 6 lines
2.14.1

_______________________________________________
ell mailing list
ell(a)lists.01.org
https://lists.01.org/mailman/listinfo/ell

--
Mat Martineau
Intel OTC

#3 lore raw

Hi Mat,

Quoted 6 lines
Quoted 2 lines

    l_free(pair->key);
+    memset(pair->value, 0, strlen(pair->value));

l_free can handle pair->value == NULL, but strlen and memset can't. Is it worth checking for that?

pair->value is always validated to be not NULL, so strictly speaking this isn't necessary. We could opt to be paranoid of course...

Regards,
-Denis