Skip to contentSkip to conversation

hotspot: fix multiple potential memory leaks

PATCH Applied James Prestwood 2 participants 4 messages Oct 16, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 hotspot: fix multiple potential memory leaks

---
 src/hotspot.c | 4 ++++
 1 file changed, 4 insertions(+)
src/hotspot.c +4 -0
index 20ebb2fd..ad8af37c 100644
@@ -423,6 +423,8 @@ static void hs20_dir_watch_cb(const char *filename,
 
 		l_queue_push_head(hs20_settings, config);
 
+		l_settings_free(new);
+
 		break;
 	case L_DIR_WATCH_EVENT_REMOVED:
 		config = l_queue_remove_if(hs20_settings, match_filename,
@@ -453,6 +455,8 @@ static void hs20_dir_watch_cb(const char *filename,
 
 		known_network_update(&config->super, new, connected_time);
 
+		l_settings_free(new);
+
 		break;
 	case L_DIR_WATCH_EVENT_ACCESSED:
 		break;
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 2/2 hotspot: check if HESSID parses correctly

---
 src/hotspot.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/hotspot.c +5 -1
index ad8af37c..e3a7a07a 100644
@@ -342,7 +342,11 @@ static struct hs20_config *hs20_config_new(struct l_settings *settings,
 	config = l_new(struct hs20_config, 1);
 
 	if (hessid_str) {
-		util_string_to_address(hessid_str, config->hessid);
+		if (!util_string_to_address(hessid_str, config->hessid)) {
+			l_error("Invalid HESSID in settings");
+			goto free_values;
+		}
+
 		l_free(hessid_str);
 	}
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v3 2/2] hotspot: check if HESSID parses correctly

Hi James,

Quoted 9 lines · James Prestwood
---
  src/hotspot.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
src/hotspot.c +0 -0
index ad8af37c..e3a7a07a 100644

src/hotspot.c static struct hs20_config *hs20_config_new(struct l_settings *settings, · line 349

Quoted 9 lines
src/hotspot.c +5 -1
@@ -342,7 +342,11 @@ static struct hs20_config *hs20_config_new(struct l_settings *settings,
  	config = l_new(struct hs20_config, 1);
 
  	if (hessid_str) {
-		util_string_to_address(hessid_str, config->hessid);
+		if (!util_string_to_address(hessid_str, config->hessid)) {
+			l_error("Invalid HESSID in settings");
+			goto free_values;
+		}
+

This still looks wrong since you're allocating config above

src/hotspot.c static struct hs20_config *hs20_config_new(struct l_settings *settings, · line 352

Quoted 4 lines
src/hotspot.c +0 -0
  		l_free(hessid_str);
  	}
 

Regards,
-Denis