return _error->Errno("write",_("Error writing to output file"));
}
- if (ExpectedSize > 0 && In.TotalWriten > ExpectedSize)
++ if (ExpectedSize > 0 && File && File->Tell() > ExpectedSize)
++ {
+ return _error->Error("Writing more data than expected (%llu > %llu)",
- In.TotalWriten, ExpectedSize);
++ File->Tell(), ExpectedSize);
++ }
+
// Handle commands from APT
if (FD_ISSET(STDIN_FILENO,&rfds))
{
public:
FileFd *File;
-
- HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), File(NULL)
+
- HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), TotalWritten(0), File(NULL)
++ HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), TotalWritten(0), File(NULL)
{
- File = 0;
curl = curl_easy_init();
};
QueueBack = Queue;
}
else
++ {
++ Server->Close();
Fail(true);
++ }
}
break;
}
--- /dev/null
--- /dev/null
++#!/bin/sh
++set -e
++
++TESTDIR=$(readlink -f $(dirname $0))
++. $TESTDIR/framework
++
++setupenvironment
++configarchitecture "i386"
++
++insertpackage 'unstable' 'apt' 'all' '1.0'
++
++setupaptarchive --no-update
++changetowebserver
++
++# normal update works fine
++testsuccess aptget update
++
++# append junk at the end of the Packages.gz/Packages
++SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
++echo "1234567890" >> aptarchive/dists/unstable/main/binary-i386/Packages.gz
++echo "1234567890" >> aptarchive/dists/unstable/main/binary-i386/Packages
++NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
++rm -f rootdir/var/lib/apt/lists/localhost*
++testequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages Writing more data than expected ($NEW_SIZE > $SIZE) [IP: ::1 8080]
++
++E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
++