Skip to contentSkip to conversation

e2freefrag: fix memory leak in scan_online()

PATCH Applied Lukas Czerner 2 participants 4 messages Jan 15, 2019 – Feb 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 e2freefrag: fix memory leak in scan_online()

---
 misc/e2freefrag.c | 1 +
 1 file changed, 1 insertion(+)
misc/e2freefrag.c +1 -0
index f7fede54..935ae225 100644
@@ -236,6 +236,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info,
 		fsmap_advance(fsmap);
 	}
 
+	free(fsmap);
 	return 1;
 }
 #else
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 e2fsprogs: fix potential memory leak in path_append()

If realloc() fails in path_append() we will lose a memory pointed to by target->path. Fix it.

---
 misc/create_inode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
misc/create_inode.c +4 -2
index 05aa6363..cedbba52 100644
@@ -704,10 +704,12 @@ struct file_info {
 static errcode_t path_append(struct file_info *target, const char *file)
 {
 	if (strlen(file) + target->path_len + 1 > target->path_max_len) {
+		void *p;
 		target->path_max_len *= 2;
-		target->path = realloc(target->path, target->path_max_len);
-		if (!target->path)
+		p = realloc(target->path, target->path_max_len);
+		if (p == NULL)
 			return EXT2_ET_NO_MEMORY;
+		target->path = p;
 	}
 	target->path_len += sprintf(target->path + target->path_len, "/%s",
 				    file);
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/2] e2fsprogs: fix potential memory leak in path_append()

Quoted 4 lines · Lukas Czerner

If realloc() fails in path_append() we will lose a memory pointed to by target->path. Fix it.

Thanks, applied.

- Ted