Bug#495906: apt: End of message missed when "\n\n" spans two reads in ReadMessages
Package: apt
Version: 0.7.14
Severity: normal
Tags: patch
ReadMessages() (in apt-pkg/contrib/strutl.cc) misses the end of a
message when the "\n\n" combination spans two reads. This is because the
first partial read is entirely put in PartialMessage and the test (I[0]
!= '\n' || I[1] != '\n') ignores the contents of PartialMessage.
The patch below should fix this:
--- strutl.cc.orig 2008-05-28 14:22:14.000000000 +0100
+++ strutl.cc 2008-08-21 09:28:05.010859100 +0100
@@ -720,8 +720,11 @@ bool ReadMessages(int Fd, vector<string>
// in PartialMessage and throw the rest of the buffer
// away. This allows us to handle messages that
// are longer than the static buffer size.
- PartialMessage += string(Buffer, End);
- End = Buffer;
+ // The last byte is left in Buffer so that a \n\n combination
+ // that spans the two reads is still detected
+ PartialMessage += string(Buffer, End-1);
+ Buffer[0] = Buffer[End-1];
+ End = Buffer + 1;
}
else
{
-- Package-specific info:
-- (no /etc/apt/preferences present) --
-- (/etc/apt/sources.list present, but not submitted) --
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: armel (armv5tejl)
Kernel: Linux 2.6.16.16-arm1
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages apt depends on:
ii debian-archive-keyring 2008.04.16+nmu1 GnuPG archive keys of the Debian a
ii libc6 2.7-13 GNU C Library: Shared libraries
ii libgcc1 1:4.3.1-2 GCC support library
ii libstdc++6 4.3.1-2 The GNU Standard C++ Library v3
apt recommends no packages.
Versions of packages apt suggests:
pn apt-doc <none> (no description available)
ii aptitude 0.4.11.8-1 terminal-based package manager
ii bzip2 1.0.5-1 high-quality block-sorting file co
ii dpkg-dev 1.14.20 Debian package development tools
ii lzma 4.43-14 Compression method of 7z format in
-- no debconf information
Reply to: