From f228636c02dc1bcb88704933b7e2049a31116d13 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 12:17:41 +0200 Subject: Merging upstream version 2.7.14. Signed-off-by: Daniel Baumann --- apt-pkg/contrib/fileutl.cc | 71 ++++++++++++++++++++------------------------ apt-pkg/deb/deblistparser.cc | 12 +++++++- apt-pkg/tagfile.cc | 5 ++++ 3 files changed, 48 insertions(+), 40 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 81e6fec..08428e7 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -2708,32 +2708,28 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) { if (d == nullptr || Failed()) return false; - ssize_t Res = 1; - errno = 0; if (Actual != 0) *Actual = 0; *((char *)To) = '\0'; - while (Res > 0 && Size > 0) + while (Size > 0) { - Res = d->InternalRead(To, Size); + errno = 0; + ssize_t Res = d->InternalRead(To, Size); if (Res < 0) { if (errno == EINTR) - { - // trick the while-loop into running again - Res = 1; - errno = 0; continue; - } return d->InternalReadError(); } - - To = (char *)To + Res; + if (Res == 0) + break; + + To = static_cast(To) + Res; Size -= Res; - if (d != NULL) + if (d != nullptr) d->set_seekpos(d->get_seekpos() + Res); - if (Actual != 0) + if (Actual != nullptr) *Actual += Res; } @@ -2751,24 +2747,22 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) } bool FileFd::Read(int const Fd, void *To, unsigned long long Size, unsigned long long * const Actual) { - ssize_t Res = 1; - errno = 0; if (Actual != nullptr) *Actual = 0; *static_cast(To) = '\0'; - while (Res > 0 && Size > 0) + while (Size > 0) { - Res = read(Fd, To, Size); + errno = 0; + ssize_t const Res = read(Fd, To, Size); if (Res < 0) { if (errno == EINTR) - { - Res = 1; - errno = 0; continue; - } return _error->Errno("read", _("Read error")); } + if (Res == 0) + break; + To = static_cast(To) + Res; Size -= Res; if (Actual != 0) @@ -2829,27 +2823,23 @@ bool FileFd::Write(const void *From,unsigned long long Size) { if (d == nullptr || Failed()) return false; - ssize_t Res = 1; - errno = 0; - while (Res > 0 && Size > 0) + while (Size > 0) { - Res = d->InternalWrite(From, Size); + errno = 0; + ssize_t const Res = d->InternalWrite(From, Size); if (Res < 0) { if (errno == EINTR) - { - // trick the while-loop into running again - Res = 1; - errno = 0; continue; - } return d->InternalWriteError(); } + if (Res == 0) + break; - From = (char const *)From + Res; + From = static_cast(From) + Res; Size -= Res; - if (d != NULL) + if (d != nullptr) d->set_seekpos(d->get_seekpos() + Res); } @@ -2860,17 +2850,20 @@ bool FileFd::Write(const void *From,unsigned long long Size) } bool FileFd::Write(int Fd, const void *From, unsigned long long Size) { - ssize_t Res = 1; - errno = 0; - while (Res > 0 && Size > 0) + while (Size > 0) { - Res = write(Fd,From,Size); - if (Res < 0 && errno == EINTR) - continue; + errno = 0; + ssize_t const Res = write(Fd, From, Size); if (Res < 0) + { + if (errno == EINTR) + continue; return _error->Errno("write",_("Write error")); + } + if (Res == 0) + break; - From = (char const *)From + Res; + From = static_cast(From) + Res; Size -= Res; } diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 8099b36..46c3629 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -522,7 +522,17 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op) Op = pkgCache::Dep::Equals; I++; break; - + + // != is unsupported packaging + case '!': + if (*(I + 1) == '=') + { + I = I + 2; + Op = pkgCache::Dep::NotEquals; + break; + } + [[fallthrough]]; + // HACK around bad package definitions default: Op = pkgCache::Dep::Equals; diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 8f323bb..95ae4a4 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -431,6 +431,11 @@ bool pkgTagFile::Fill() that is there */ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset) { + // Head back to the start of the buffer, in case we get called for the same section + // again (d->Start will point to next section already) + d->iOffset -= d->Start - d->Buffer; + d->Start = d->Buffer; + if ((d->Flags & pkgTagFile::SUPPORT_COMMENTS) == 0 && // We are within a buffer space of the next hit.. Offset >= d->iOffset && d->iOffset + (d->End - d->Start) > Offset) -- cgit v1.2.3