ソースを参照

libdpkg: Do not return from 0 sized buffer_copy() w/o doing filtering

This changes the function to handle the case of a caller specified 0 size
in the same way as if the size requested was dynamic (-1), and there were
0 bytes read, i.e. perform at least the initialization and shutdown of
the filter so that it can compute any required value, if needed.

As an optimization, given that we do not return early from the function
anymore, do not allocate the buffer when the buffer size is 0.

This comes up on 0 sized extracted files, which ended up w/o a computed
hash.
Guillem Jover 14 年 前
コミット
a9f88f151c
共有2 個のファイルを変更した7 個の追加4 個の削除を含む
  1. 3 0
      debian/changelog
  2. 4 4
      lib/dpkg/buffer.c

+ 3 - 0
debian/changelog

@@ -37,6 +37,9 @@ dpkg (1.16.3) UNRELEASED; urgency=low
     are supported in symbols files. Closes: #670048
   * Fix memory leak due to Dpkg::Control objects not being garbage-collected.
     Thanks to Ben Harris <bjh21@cam.ac.uk>. Closes: #669012
+  * Compute the md5sum hash on unpack for empty files too, so that these
+    can be checked correctly for matching content when installing multiple
+    package instances.
 
   [ Helge Kreutzmann ]
   * Fix a typo in man/dpkg-buildflags.1.

+ 4 - 4
lib/dpkg/buffer.c

@@ -4,7 +4,7 @@
  *
  * Copyright © 1999, 2000 Wichert Akkerman <wakkerma@debian.org>
  * Copyright © 2000-2003 Adam Heath <doogie@debian.org>
- * Copyright © 2008-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -181,9 +181,9 @@ buffer_copy(struct buffer_data *read_data,
 	if ((limit != -1) && (limit < bufsize))
 		bufsize = limit;
 	if (bufsize == 0)
-		return 0;
-
-	buf = m_malloc(bufsize);
+		buf = NULL;
+	else
+		buf = m_malloc(bufsize);
 
 	buffer_filter_init(filter);