Bug#725483: apt: libapt-inst fails with >2G debs
On Sun, Oct 06, 2013 at 12:02:34PM +0100, Mark Hymers wrote:
> Package: apt
> Version: 0.9.11.4
> Severity: important
> Tags: lfs patch
Thanks for your bugreport and your patch.
> Whilst doing some dak testing with large (fake) debs for
> data.debian.org, I came across an issue with the following test code:
[..]
> Attached are two patches - one for the version of apt in sid, one for
> wheezy which fix the problem - I've checked that we can then extract the
> control and data members properly with these fixes and it seems to work
> fine.
>
> I'm not an expert C++ programmer so I'd appreciate someone reviewing
> these patches to see if they're sane.
The patch looks good, I merged it into the git tree and it will be
part of the next upload.
> Assuming the patches are
> acceptable, from the ftpmaster point of view, we probably need to talk
> to the stable team about getting this patched in stable too because dak
> uses the python-apt bindings (which in turn use libapt-inst and
> libapt-pkg) and as franck.d.o runs stable, we'll need this fixing to get
> data.d.o up and running.
I'm happy to add the patch to the debian/wheezy branch and upload a
new version, just let me know if the stable team is fine with that.
Thanks!
Michael
> Thanks,
>
> Mark
>
> -- Package-specific info:
>
> -- (no /etc/apt/preferences present) --
>
>
> -- (/etc/apt/sources.list present, but not submitted) --
>
>
> -- System Information:
> Debian Release: jessie/sid
> APT prefers unstable
> APT policy: (500, 'unstable')
> Architecture: amd64 (x86_64)
>
> Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
> Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
>
> Versions of packages apt depends on:
> ii debian-archive-keyring 2012.4
> ii gnupg 1.4.14-1
> ii libapt-pkg4.12 0.9.11.4
> ii libc6 2.17-93
> ii libgcc1 1:4.8.1-10
> ii libstdc++6 4.8.1-10
>
> apt recommends no packages.
>
> Versions of packages apt suggests:
> pn apt-doc <none>
> ii aptitude 0.6.8.2-1.2
> ii dpkg-dev 1.17.1
> ii python-apt 0.8.9.1+b1
> ii xz-utils 5.1.1alpha+20120614-2
>
> -- no debconf information
> diff --git a/apt-inst/contrib/arfile.cc b/apt-inst/contrib/arfile.cc
> index 2dee1a4..b77c77d 100644
> --- a/apt-inst/contrib/arfile.cc
> +++ b/apt-inst/contrib/arfile.cc
> @@ -64,7 +64,7 @@ ARArchive::~ARArchive()
> byte plain text header then the file data, another header, data, etc */
> bool ARArchive::LoadHeaders()
> {
> - signed long Left = File.Size();
> + off_t Left = File.Size();
>
> // Check the magic byte
> char Magic[8];
> @@ -120,7 +120,7 @@ bool ARArchive::LoadHeaders()
> }
>
> // Account for the AR header alignment
> - unsigned Skip = Memb->Size % 2;
> + off_t Skip = Memb->Size % 2;
>
> // Add it to the list
> Memb->Next = List;
> @@ -128,7 +128,7 @@ bool ARArchive::LoadHeaders()
> Memb->Start = File.Tell();
> if (File.Skip(Memb->Size + Skip) == false)
> return false;
> - if (Left < (signed)(Memb->Size + Skip))
> + if (Left < (off_t)(Memb->Size + Skip))
> return _error->Error(_("Archive is too short"));
> Left -= Memb->Size + Skip;
> }
> diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
> index 90e49cb..136a9d7 100644
> --- a/apt-pkg/contrib/fileutl.cc
> +++ b/apt-pkg/contrib/fileutl.cc
> @@ -650,9 +650,9 @@ string flNoLink(string File)
> while (1)
> {
> // Read the link
> - int Res;
> + ssize_t Res;
> if ((Res = readlink(NFile.c_str(),Buffer,sizeof(Buffer))) <= 0 ||
> - (unsigned)Res >= sizeof(Buffer))
> + (size_t)Res >= sizeof(Buffer))
> return File;
>
> // Append or replace the previous path
> @@ -1221,7 +1221,7 @@ FileFd::~FileFd()
> gracefully. */
> bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
> {
> - int Res;
> + ssize_t Res;
> errno = 0;
> if (Actual != 0)
> *Actual = 0;
> @@ -1323,7 +1323,7 @@ char* FileFd::ReadLine(char *To, unsigned long long const Size)
> /* */
> bool FileFd::Write(const void *From,unsigned long long Size)
> {
> - int Res;
> + ssize_t Res;
> errno = 0;
> do
> {
> @@ -1379,7 +1379,7 @@ bool FileFd::Write(const void *From,unsigned long long Size)
> }
> bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
> {
> - int Res;
> + ssize_t Res;
> errno = 0;
> do
> {
> @@ -1458,14 +1458,14 @@ bool FileFd::Seek(unsigned long long To)
> d->seekpos = To;
> return true;
> }
> - int res;
> + off_t res;
> #ifdef HAVE_ZLIB
> if (d != NULL && d->gz)
> res = gzseek(d->gz,To,SEEK_SET);
> else
> #endif
> res = lseek(iFd,To,SEEK_SET);
> - if (res != (signed)To)
> + if (res != (off_t)To)
> {
> Flags |= Fail;
> return _error->Error("Unable to seek to %llu", To);
> @@ -1502,7 +1502,7 @@ bool FileFd::Skip(unsigned long long Over)
> return true;
> }
>
> - int res;
> + off_t res;
> #ifdef HAVE_ZLIB
> if (d != NULL && d->gz != NULL)
> res = gzseek(d->gz,Over,SEEK_CUR);
> diff --git a/apt-inst/contrib/arfile.cc b/apt-inst/contrib/arfile.cc
> index d7ee528..9d84c17 100644
> --- a/apt-inst/contrib/arfile.cc
> +++ b/apt-inst/contrib/arfile.cc
> @@ -64,7 +64,7 @@ ARArchive::~ARArchive()
> byte plain text header then the file data, another header, data, etc */
> bool ARArchive::LoadHeaders()
> {
> - signed long Left = File.Size();
> + off_t Left = File.Size();
>
> // Check the magic byte
> char Magic[8];
> @@ -123,7 +123,7 @@ bool ARArchive::LoadHeaders()
> }
>
> // Account for the AR header alignment
> - unsigned Skip = Memb->Size % 2;
> + off_t Skip = Memb->Size % 2;
>
> // Add it to the list
> Memb->Next = List;
> @@ -131,7 +131,7 @@ bool ARArchive::LoadHeaders()
> Memb->Start = File.Tell();
> if (File.Skip(Memb->Size + Skip) == false)
> return false;
> - if (Left < (signed)(Memb->Size + Skip))
> + if (Left < (off_t)(Memb->Size + Skip))
> return _error->Error(_("Archive is too short"));
> Left -= Memb->Size + Skip;
> }
> diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
> index 3966eb0..0261119 100644
> --- a/apt-pkg/contrib/fileutl.cc
> +++ b/apt-pkg/contrib/fileutl.cc
> @@ -656,9 +656,9 @@ string flNoLink(string File)
> while (1)
> {
> // Read the link
> - int Res;
> + ssize_t Res;
> if ((Res = readlink(NFile.c_str(),Buffer,sizeof(Buffer))) <= 0 ||
> - (unsigned)Res >= sizeof(Buffer))
> + (size_t)Res >= sizeof(Buffer))
> return File;
>
> // Append or replace the previous path
> @@ -1244,7 +1244,7 @@ FileFd::~FileFd()
> gracefully. */
> bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
> {
> - int Res;
> + ssize_t Res;
> errno = 0;
> if (Actual != 0)
> *Actual = 0;
> @@ -1344,7 +1344,7 @@ char* FileFd::ReadLine(char *To, unsigned long long const Size)
> /* */
> bool FileFd::Write(const void *From,unsigned long long Size)
> {
> - int Res;
> + ssize_t Res;
> errno = 0;
> do
> {
> @@ -1398,7 +1398,7 @@ bool FileFd::Write(const void *From,unsigned long long Size)
> }
> bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
> {
> - int Res;
> + ssize_t Res;
> errno = 0;
> do
> {
> @@ -1471,14 +1471,14 @@ bool FileFd::Seek(unsigned long long To)
> d->seekpos = To;
> return true;
> }
> - int res;
> + off_t res;
> #ifdef HAVE_ZLIB
> if (d != NULL && d->gz)
> res = gzseek(d->gz,To,SEEK_SET);
> else
> #endif
> res = lseek(iFd,To,SEEK_SET);
> - if (res != (signed)To)
> + if (res != (off_t)To)
> return FileFdError("Unable to seek to %llu", To);
>
> if (d != NULL)
> @@ -1509,7 +1509,7 @@ bool FileFd::Skip(unsigned long long Over)
> return true;
> }
>
> - int res;
> + off_t res;
> #ifdef HAVE_ZLIB
> if (d != NULL && d->gz != NULL)
> res = gzseek(d->gz,Over,SEEK_CUR);
Reply to: