[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#545694: apt: rred fails when patch is only prepending text



Package: apt
Version: 0.7.23.1
Severity: normal
Tags: patch

When a Packages.diff ed file only contains a single "0a" chunk
(for example when only a package sorting before all other packages
is added), then rred fails because of a broken test.
(It only tests if the last line after which things were added
is bigger than zero).

The following change in rred.c fixes that for me (patch attached):

    /* read the rest from infile */
-   if (result > 0) {
+   if (result >= 0) {
       while (fgets(buffer, BUF_SIZE, in_file) != NULL) {

Hochachtungsvoll,
	Bernhard R. Link
=== modified file 'methods/rred.cc'
--- methods/rred.cc	2006-05-17 15:58:24 +0000
+++ methods/rred.cc	2009-09-08 14:06:29 +0000
@@ -174,7 +174,7 @@
          hash);
    
    /* read the rest from infile */
-   if (result > 0) {
+   if (result >= 0) {
       while (fgets(buffer, BUF_SIZE, in_file) != NULL) {
          written = fwrite(buffer, 1, strlen(buffer), out_file);
          hash->Add((unsigned char*)buffer, written);


Reply to: