Explorar el Código

libdpkg: Do not leak every tar_entry name and linkname members

The only free()ed members were the last ones.
Guillem Jover hace 14 años
padre
commit
6f5374204b
Se han modificado 3 ficheros con 4 adiciones y 2 borrados
  1. 0 1
      TODO
  2. 1 0
      debian/changelog
  3. 3 1
      lib/dpkg/tarfn.c

+ 0 - 1
TODO

@@ -52,7 +52,6 @@ TODO
    - Handle instdir '/' separator consistently.
    - Handle instdir '/' separator consistently.
    - Check if caching selinux context for second call is possible.
    - Check if caching selinux context for second call is possible.
    - Add missing newlines in --version output.
    - Add missing newlines in --version output.
-   - Fix leak on tar_extract (name, linkname).
    - Handle symlinks in statcmd.c statdb_node_apply().
    - Handle symlinks in statcmd.c statdb_node_apply().
    - Fix dpkg termination on SIGPIPE from status-fd.
    - Fix dpkg termination on SIGPIPE from status-fd.
 
 

+ 1 - 0
debian/changelog

@@ -26,6 +26,7 @@ dpkg (1.16.2) UNRELEASED; urgency=low
     using the ‘--warning=no-timestamp’ option. Closes: 642802
     using the ‘--warning=no-timestamp’ option. Closes: 642802
   * Do not segfault on GNU/Linux when dpkg cannot retrieve the block size
   * Do not segfault on GNU/Linux when dpkg cannot retrieve the block size
     for the filesystem containing the info database. LP: #872734
     for the filesystem containing the info database. LP: #872734
+  * Fix two memory leaks per tar entry in the tar extractor used on unpack.
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Update Dpkg::Shlibs to look into multiarch paths when cross-building
   * Update Dpkg::Shlibs to look into multiarch paths when cross-building

+ 3 - 1
lib/dpkg/tarfn.c

@@ -308,6 +308,7 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
 				errno = 0;
 				errno = 0;
 				status = -1;
 				status = -1;
 			}
 			}
+			tar_entry_destroy(&h);
 			break;
 			break;
 		}
 		}
 		if (h.type != tar_filetype_gnu_longlink &&
 		if (h.type != tar_filetype_gnu_longlink &&
@@ -326,6 +327,7 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
 			/* Indicates broken tarfile: “Bad header data”. */
 			/* Indicates broken tarfile: “Bad header data”. */
 			errno = 0;
 			errno = 0;
 			status = -1;
 			status = -1;
+			tar_entry_destroy(&h);
 			break;
 			break;
 		}
 		}
 
 
@@ -378,6 +380,7 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
 			errno = 0;
 			errno = 0;
 			status = -1;
 			status = -1;
 		}
 		}
+		tar_entry_destroy(&h);
 		if (status != 0)
 		if (status != 0)
 			/* Pass on status from coroutine. */
 			/* Pass on status from coroutine. */
 			break;
 			break;
@@ -391,7 +394,6 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
 		free(symlink_head);
 		free(symlink_head);
 		symlink_head = symlink_node;
 		symlink_head = symlink_node;
 	}
 	}
-	tar_entry_destroy(&h);
 
 
 	if (status > 0) {
 	if (status > 0) {
 		/* Indicates broken tarfile: “Read partial header record”. */
 		/* Indicates broken tarfile: “Read partial header record”. */