summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-05-12 11:49:09 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2020-05-12 18:55:55 +0200
commitdceb1e49e4b8e4dadaf056be34088b415939cda6 (patch)
tree4ab3099ce613d9350dbaea5540aca48eab095498 /apt-pkg/contrib
parent3e7ffa3c1e1afde99182fd4cc91b5536ed8a11da (diff)
SECURITY UPDATE: Fix out of bounds read in .ar and .tar implementation (CVE-2020-3810)
When normalizing ar member names by removing trailing whitespace and slashes, an out-out-bound read can be caused if the ar member name consists only of such characters, because the code did not stop at 0, but would wrap around and continue reading from the stack, without any limit. Add a check to abort if we reached the first character in the name, effectively rejecting the use of names consisting just of slashes and spaces. Furthermore, certain error cases in arfile.cc and extracttar.cc have included member names in the output that were not checked at all and might hence not be nul terminated, leading to further out of bound reads. Fixes Debian/apt#111 LP: #1878177
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/arfile.cc11
-rw-r--r--apt-pkg/contrib/extracttar.cc2
2 files changed, 10 insertions, 3 deletions
diff --git a/apt-pkg/contrib/arfile.cc b/apt-pkg/contrib/arfile.cc
index 3fc3afedb..5cb43c690 100644
--- a/apt-pkg/contrib/arfile.cc
+++ b/apt-pkg/contrib/arfile.cc
@@ -92,7 +92,7 @@ bool ARArchive::LoadHeaders()
StrToNum(Head.Size,Memb->Size,sizeof(Head.Size)) == false)
{
delete Memb;
- return _error->Error(_("Invalid archive member header %s"), Head.Name);
+ return _error->Error(_("Invalid archive member header"));
}
// Check for an extra long name string
@@ -119,7 +119,14 @@ bool ARArchive::LoadHeaders()
else
{
unsigned int I = sizeof(Head.Name) - 1;
- for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--);
+ for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--)
+ {
+ if (I == 0)
+ {
+ delete Memb;
+ return _error->Error(_("Invalid archive member header"));
+ }
+ }
Memb->Name = std::string(Head.Name,I+1);
}
diff --git a/apt-pkg/contrib/extracttar.cc b/apt-pkg/contrib/extracttar.cc
index 9bb0a55c0..b22f59dbc 100644
--- a/apt-pkg/contrib/extracttar.cc
+++ b/apt-pkg/contrib/extracttar.cc
@@ -254,7 +254,7 @@ bool ExtractTar::Go(pkgDirStream &Stream)
default:
BadRecord = true;
- _error->Warning(_("Unknown TAR header type %u, member %s"),(unsigned)Tar->LinkFlag,Tar->Name);
+ _error->Warning(_("Unknown TAR header type %u"), (unsigned)Tar->LinkFlag);
break;
}