Просмотр исходного кода

libdpkg: Fix use after free in dpkg_arch_load_list()

Reported-by: Pedro Ribeiro <pedrib@gmail.com>
Guillem Jover лет назад: 13
Родитель
Сommit
72f4e49f96
2 измененных файлов с 4 добавлено и 1 удалено
  1. 2 0
      debian/changelog
  2. 2 1
      lib/dpkg/arch.c

+ 2 - 0
debian/changelog

@@ -16,6 +16,8 @@ dpkg (1.17.2) UNRELEASED; urgency=low
   * Clarify the insertion order of _ members in deb(5) man page.
   * Fix use after free in alternative_parse_fileset() on update-alternatives.
     Reported by Pedro Ribeiro <pedrib@gmail.com>.
+  * Fix use after free in dpkg_arch_load_list() on libdpkg.
+    Reported by Pedro Ribeiro <pedrib@gmail.com>.
 
  -- Guillem Jover <guillem@debian.org>  Sun, 28 Jul 2013 15:06:29 +0200
 

+ 2 - 1
lib/dpkg/arch.c

@@ -289,15 +289,16 @@ dpkg_arch_load_list(void)
 
 	archfile = dpkg_db_get_path(DPKG_DB_ARCH_FILE);
 	fp = fopen(archfile, "r");
-	free(archfile);
 	if (fp == NULL) {
 		arch_list_dirty = true;
+		free(archfile);
 		return;
 	}
 
 	while (fgets_checked(archname, sizeof(archname), fp, archfile) >= 0)
 		dpkg_arch_add(archname);
 
+	free(archfile);
 	fclose(fp);
 }