summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-item.cc57
-rw-r--r--apt-pkg/acquire-item.h45
-rw-r--r--apt-pkg/acquire-worker.cc2
-rw-r--r--apt-pkg/cachefile.cc4
-rw-r--r--apt-pkg/contrib/cdromutl.cc2
-rw-r--r--apt-pkg/contrib/gpgv.cc2
-rw-r--r--apt-pkg/deb/debmetaindex.cc2
-rw-r--r--apt-pkg/deb/debrecords.cc4
-rw-r--r--apt-pkg/deb/dpkgpm.cc4
-rw-r--r--apt-pkg/indexrecords.cc5
-rw-r--r--apt-pkg/tagfile.cc13
-rw-r--r--apt-pkg/tagfile.h2
-rw-r--r--apt-private/private-cacheset.h13
-rw-r--r--apt-private/private-output.cc23
-rw-r--r--buildlib/environment.mak.in2
-rw-r--r--cmdline/apt-cache.cc1
-rw-r--r--cmdline/apt-get.cc8
-rw-r--r--ftparchive/apt-ftparchive.cc69
-rw-r--r--ftparchive/cachedb.cc1
-rw-r--r--ftparchive/writer.cc31
-rw-r--r--ftparchive/writer.h14
-rw-r--r--test/integration/framework3
-rw-r--r--test/libapt/cdrom_test.cc7
-rw-r--r--test/libapt/file-helpers.cc7
-rw-r--r--test/libapt/file-helpers.h2
-rw-r--r--test/libapt/sourcelist_test.cc5
26 files changed, 190 insertions, 138 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 222ca8931..0ab52a0cd 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -109,7 +109,7 @@ static std::string GetDiffsPatchFileName(std::string const &Final) /*{{{*/
}
/*}}}*/
-static bool AllowInsecureRepositories(indexRecords const * const MetaIndexParser, pkgAcqMetaBase * const TransactionManager, pkgAcquire::Item * const I) /*{{{*/
+static bool AllowInsecureRepositories(indexRecords const * const MetaIndexParser, pkgAcqMetaClearSig * const TransactionManager, pkgAcquire::Item * const I) /*{{{*/
{
if(MetaIndexParser->IsAlwaysTrusted() || _config->FindB("Acquire::AllowInsecureRepositories") == true)
return true;
@@ -661,7 +661,7 @@ std::string pkgAcquire::Item::HashSum() const /*{{{*/
/*}}}*/
pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner, /*{{{*/
- pkgAcqMetaBase * const transactionManager, IndexTarget const &target) :
+ pkgAcqMetaClearSig * const transactionManager, IndexTarget const &target) :
pkgAcquire::Item(Owner), d(NULL), Target(target), TransactionManager(transactionManager)
{
if (TransactionManager != this)
@@ -680,12 +680,11 @@ HashStringList pkgAcqTransactionItem::GetExpectedHashesFor(std::string const &Me
// AcqMetaBase - Constructor /*{{{*/
pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
std::vector<IndexTarget> const &IndexTargets,
- IndexTarget const &DataTarget,
- indexRecords * const MetaIndexParser)
+ IndexTarget const &DataTarget)
: pkgAcqTransactionItem(Owner, TransactionManager, DataTarget), d(NULL),
- MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL), IndexTargets(IndexTargets),
+ IndexTargets(IndexTargets),
AuthPass(false), IMSHit(false)
{
}
@@ -1047,7 +1046,7 @@ bool pkgAcqMetaBase::VerifyVendor(string const &Message) /*{{{*/
std::string errmsg;
strprintf(errmsg,
// TRANSLATOR: The first %s is the URL of the bad Release file, the second is
- // the time since then the file is invalid - formated in the same way as in
+ // the time since then the file is invalid - formatted in the same way as in
// the download progress display (e.g. 7d 3h 42min 1s)
_("Release file for %s is expired (invalid since %s). "
"Updates for this repository will not be applied."),
@@ -1098,16 +1097,19 @@ bool pkgAcqMetaBase::VerifyVendor(string const &Message) /*{{{*/
return true;
}
/*}}}*/
-pkgAcqMetaBase::~pkgAcqMetaBase() {}
+pkgAcqMetaBase::~pkgAcqMetaBase()
+{
+}
pkgAcqMetaClearSig::pkgAcqMetaClearSig(pkgAcquire * const Owner, /*{{{*/
IndexTarget const &ClearsignedTarget,
IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget,
std::vector<IndexTarget> const &IndexTargets,
indexRecords * const MetaIndexParser) :
- pkgAcqMetaIndex(Owner, this, ClearsignedTarget, DetachedSigTarget, IndexTargets, MetaIndexParser),
+ pkgAcqMetaIndex(Owner, this, ClearsignedTarget, DetachedSigTarget, IndexTargets),
d(NULL), ClearsignedTarget(ClearsignedTarget),
- DetachedDataTarget(DetachedDataTarget)
+ DetachedDataTarget(DetachedDataTarget),
+ MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL)
{
// index targets + (worst case:) Release/Release.gpg
ExpectedAdditionalItems = IndexTargets.size() + 2;
@@ -1116,6 +1118,10 @@ pkgAcqMetaClearSig::pkgAcqMetaClearSig(pkgAcquire * const Owner, /*{{{*/
/*}}}*/
pkgAcqMetaClearSig::~pkgAcqMetaClearSig() /*{{{*/
{
+ if (MetaIndexParser != NULL)
+ delete MetaIndexParser;
+ if (LastMetaIndexParser != NULL)
+ delete LastMetaIndexParser;
}
/*}}}*/
// pkgAcqMetaClearSig::Custom600Headers - Insert custom request headers /*{{{*/
@@ -1180,7 +1186,7 @@ void pkgAcqMetaClearSig::Failed(string const &Message,pkgAcquire::MethodConfig c
TransactionManager->TransactionStageRemoval(this, GetFinalFilename());
Status = StatDone;
- new pkgAcqMetaIndex(Owner, TransactionManager, DetachedDataTarget, DetachedSigTarget, IndexTargets, TransactionManager->MetaIndexParser);
+ new pkgAcqMetaIndex(Owner, TransactionManager, DetachedDataTarget, DetachedSigTarget, IndexTargets);
}
else
{
@@ -1240,12 +1246,11 @@ void pkgAcqMetaClearSig::Failed(string const &Message,pkgAcquire::MethodConfig c
/*}}}*/
pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire * const Owner, /*{{{*/
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &DataTarget,
IndexTarget const &DetachedSigTarget,
- vector<IndexTarget> const &IndexTargets,
- indexRecords * const MetaIndexParser) :
- pkgAcqMetaBase(Owner, TransactionManager, IndexTargets, DataTarget, MetaIndexParser), d(NULL),
+ vector<IndexTarget> const &IndexTargets) :
+ pkgAcqMetaBase(Owner, TransactionManager, IndexTargets, DataTarget), d(NULL),
DetachedSigTarget(DetachedSigTarget)
{
if(_config->FindB("Debug::Acquire::Transaction", false) == true)
@@ -1324,7 +1329,7 @@ pkgAcqMetaIndex::~pkgAcqMetaIndex() {}
// AcqMetaSig::AcqMetaSig - Constructor /*{{{*/
pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
pkgAcqMetaIndex * const MetaIndex) :
pkgAcqTransactionItem(Owner, TransactionManager, Target), d(NULL), MetaIndex(MetaIndex)
@@ -1487,7 +1492,7 @@ void pkgAcqMetaSig::Failed(string const &Message,pkgAcquire::MethodConfig const
// AcqBaseIndex - Constructor /*{{{*/
pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target)
: pkgAcqTransactionItem(Owner, TransactionManager, Target), d(NULL)
{
@@ -1503,9 +1508,9 @@ pkgAcqBaseIndex::~pkgAcqBaseIndex() {}
* the original packages file
*/
pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target)
- : pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL)
+ : pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL), diffs(NULL)
{
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
@@ -1840,7 +1845,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, available_patches);
else
{
- std::vector<pkgAcqIndexMergeDiffs*> *diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
+ diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
for(size_t i = 0; i < available_patches.size(); ++i)
(*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, TransactionManager,
Target,
@@ -1896,7 +1901,11 @@ void pkgAcqDiffIndex::Done(string const &Message,HashStringList const &Hashes, /
return;
}
/*}}}*/
-pkgAcqDiffIndex::~pkgAcqDiffIndex() {}
+pkgAcqDiffIndex::~pkgAcqDiffIndex()
+{
+ if (diffs != NULL)
+ delete diffs;
+}
// AcqIndexDiffs::AcqIndexDiffs - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -1904,7 +1913,7 @@ pkgAcqDiffIndex::~pkgAcqDiffIndex() {}
* for each diff and the index
*/
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
vector<DiffInfo> const &diffs)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL),
@@ -2127,7 +2136,7 @@ pkgAcqIndexDiffs::~pkgAcqIndexDiffs() {}
// AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/
pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
@@ -2272,7 +2281,7 @@ pkgAcqIndexMergeDiffs::~pkgAcqIndexMergeDiffs() {}
// AcqIndex::AcqIndex - Constructor /*{{{*/
pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL), Stage(STAGE_DOWNLOAD)
{
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index c4bbfc7a1..4d235dce2 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -46,7 +46,8 @@
class indexRecords;
class pkgRecords;
class pkgSourceList;
-class pkgAcqMetaBase;
+class pkgAcqMetaClearSig;
+class pkgAcqIndexMergeDiffs;
class pkgAcquire::Item : public WeakPointable /*{{{*/
/** \brief Represents the process by which a pkgAcquire object should
@@ -339,6 +340,7 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/
void * const d;
friend class pkgAcqMetaBase;
+ friend class pkgAcqMetaClearSig;
};
/*}}}*/
class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
@@ -356,7 +358,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
std::string PartialFile;
/** \brief TransactionManager */
- pkgAcqMetaBase * const TransactionManager;
+ pkgAcqMetaClearSig * const TransactionManager;
enum TransactionStates {
TransactionCommit,
@@ -370,10 +372,11 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
virtual bool HashesRequired() const;
- pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const &Target);
+ pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target);
virtual ~pkgAcqTransactionItem();
friend class pkgAcqMetaBase;
+ friend class pkgAcqMetaClearSig;
};
/*}}}*/
class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
@@ -383,12 +386,6 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
protected:
std::vector<pkgAcqTransactionItem*> Transaction;
- public:
- /** \brief A package-system-specific parser for the meta-index file. */
- indexRecords *MetaIndexParser;
- indexRecords *LastMetaIndexParser;
- protected:
-
/** \brief The index files which should be looked up in the meta-index
* and then downloaded.
*/
@@ -473,10 +470,9 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
/** \brief Get the full pathname of the final file for the current URI */
virtual std::string GetFinalFilename() const;
- pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
std::vector<IndexTarget> const &IndexTargets,
- IndexTarget const &DataTarget,
- indexRecords* const MetaIndexParser);
+ IndexTarget const &DataTarget);
virtual ~pkgAcqMetaBase();
};
/*}}}*/
@@ -509,9 +505,9 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
virtual void Finished();
/** \brief Create a new pkgAcqMetaIndex. */
- pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
- std::vector<IndexTarget> const &IndexTargets, indexRecords * const MetaIndexParser);
+ std::vector<IndexTarget> const &IndexTargets);
virtual ~pkgAcqMetaIndex();
friend class pkgAcqMetaSig;
@@ -548,8 +544,8 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
pkgAcquire::MethodConfig const * const Cnf);
/** \brief Create a new pkgAcqMetaSig. */
- pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const &Target,
- pkgAcqMetaIndex * const MetaIndex);
+ pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
+ IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex);
virtual ~pkgAcqMetaSig();
};
/*}}}*/
@@ -561,7 +557,11 @@ class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex
IndexTarget const ClearsignedTarget;
IndexTarget const DetachedDataTarget;
-public:
+ public:
+ /** \brief A package-system-specific parser for the meta-index file. */
+ indexRecords *MetaIndexParser;
+ indexRecords *LastMetaIndexParser;
+
virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
virtual std::string Custom600Headers() const;
virtual void Done(std::string const &Message, HashStringList const &Hashes,
@@ -586,7 +586,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
/** \brief Get the full pathname of the final file for the current URI */
virtual std::string GetFinalFilename() const;
- pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target);
virtual ~pkgAcqBaseIndex();
};
@@ -603,6 +603,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
{
void * const d;
+ std::vector<pkgAcqIndexMergeDiffs*> * diffs;
protected:
/** \brief If \b true, debugging information will be written to std::clog. */
@@ -650,7 +651,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
*
* \param ShortDesc A short description of the list file to download.
*/
- pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target);
virtual ~pkgAcqDiffIndex();
private:
@@ -749,7 +750,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
* \param allPatches contains all related items so that each item can
* check if it was the last one to complete the download step
*/
- pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target, DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
virtual ~pkgAcqIndexMergeDiffs();
@@ -863,7 +864,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
* should be ordered so that each diff appears before any diff
* that depends on it.
*/
- pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
virtual ~pkgAcqIndexDiffs();
@@ -941,7 +942,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
virtual std::string DescURI() const {return Desc.URI;};
virtual std::string GetMetaKey() const;
- pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+ pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target);
virtual ~pkgAcqIndex();
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 8d619e96d..c0f93f9ce 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -722,7 +722,7 @@ void pkgAcquire::Worker::PrepareFiles(char const * const caller, pkgAcquire::Que
unlink(Owner->DestFile.c_str());
if (link(filename.c_str(), Owner->DestFile.c_str()) != 0)
{
- // diferent mounts can't happen for us as we download to lists/ by default,
+ // different mounts can't happen for us as we download to lists/ by default,
// but if the system is reused by others the locations can potentially be on
// different disks, so use symlink as poor-men replacement.
// FIXME: Real copying as last fallback, but that is costly, so offload to a method preferable
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index ea3d45480..690776266 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -65,8 +65,8 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
if (_config->FindB("pkgCacheFile::Generate", true) == false)
{
- Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),
- FileFd::ReadOnly),MMap::Public|MMap::ReadOnly);
+ FileFd file(_config->FindFile("Dir::Cache::pkgcache"), FileFd::ReadOnly);
+ Map = new MMap(file, MMap::Public|MMap::ReadOnly);
Cache = new pkgCache(Map);
if (_error->PendingError() == true)
return false;
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 6eb917457..428ef0161 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -287,9 +287,11 @@ string FindMountPointForDevice(const char *devnode)
fclose(f);
// unescape the \0XXX chars in the path
string mount_point = out[1];
+ free(line);
return DeEscapeString(mount_point);
}
fclose(f);
+ free(line);
}
return string();
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 9d798cca9..a01e319eb 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -296,6 +296,8 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
// all the rest is whitespace, unsigned garbage or additional message blocks we ignore
}
fclose(in);
+ if (buf != NULL)
+ free(buf);
if (found_signature == true)
return _error->Error("Signature in file %s wasn't closed", InFile.c_str());
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 026af077f..5a517b290 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -270,7 +270,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
// special case for --print-uris
std::vector<IndexTarget> const targets = GetIndexTargets();
#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
- pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
+ pkgAcqMetaClearSig * const TransactionManager = new pkgAcqMetaClearSig(Owner,
APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
targets, iR);
#undef APT_TARGET
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 326102d08..d78a7e2e0 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -42,10 +42,14 @@ debRecordParser::debRecordParser(string FileName,pkgCache &Cache) :
// RecordParser::Jump - Jump to a specific record /*{{{*/
bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
{
+ if (Ver.end() == true)
+ return false;
return Tags.Jump(Section,Ver->Offset);
}
bool debRecordParser::Jump(pkgCache::DescFileIterator const &Desc)
{
+ if (Desc.end() == true)
+ return false;
return Tags.Jump(Section,Desc->Offset);
}
/*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 1991a4a66..3594a6efe 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1484,6 +1484,10 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
a != Args.end(); ++a)
clog << *a << ' ';
clog << endl;
+ for (std::vector<char *>::const_iterator p = Packages.begin();
+ p != Packages.end(); ++p)
+ free(*p);
+ Packages.clear();
continue;
}
Args.push_back(NULL);
diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc
index 5a93d826f..03ba59460 100644
--- a/apt-pkg/indexrecords.cc
+++ b/apt-pkg/indexrecords.cc
@@ -278,4 +278,7 @@ indexRecords::indexRecords(const string &ExpectedDist) :
{
}
-indexRecords::~indexRecords() {}
+indexRecords::~indexRecords() {
+ for (std::map<std::string, checkSum*>::const_iterator S = Entries.begin(); S != Entries.end(); ++S)
+ delete S->second;
+}
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 4c5505bf3..6d7d8185b 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -34,8 +34,10 @@ class pkgTagFilePrivate
public:
void Reset(FileFd * const pFd, unsigned long long const pSize)
{
- Fd = pFd;
+ if (Buffer != NULL)
+ free(Buffer);
Buffer = NULL;
+ Fd = pFd;
Start = NULL;
End = NULL;
Done = false;
@@ -43,7 +45,7 @@ public:
Size = pSize;
}
- pkgTagFilePrivate(FileFd * const pFd, unsigned long long const Size)
+ pkgTagFilePrivate(FileFd * const pFd, unsigned long long const Size) : Buffer(NULL)
{
Reset(pFd, Size);
}
@@ -54,6 +56,12 @@ public:
bool Done;
unsigned long long iOffset;
unsigned long long Size;
+
+ ~pkgTagFilePrivate()
+ {
+ if (Buffer != NULL)
+ free(Buffer);
+ }
};
class pkgTagSectionPrivate
@@ -127,7 +135,6 @@ void pkgTagFile::Init(FileFd * const pFd,unsigned long long Size)
/* */
pkgTagFile::~pkgTagFile()
{
- free(d->Buffer);
delete d;
}
/*}}}*/
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 23238d979..d0d0c7a84 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -136,7 +136,7 @@ class pkgTagSection
*
* @param File to write the section to
* @param Order in which tags should appear in the file
- * @param Rewrite is a set of tags to be renamed, rewitten and/or removed
+ * @param Rewrite is a set of tags to be renamed, rewritten and/or removed
* @return \b true if successful, otherwise \b false
*/
bool Write(FileFd &File, char const * const * const Order = NULL, std::vector<Tag> const &Rewrite = std::vector<Tag>()) const;
diff --git a/apt-private/private-cacheset.h b/apt-private/private-cacheset.h
index 059c7637e..0eb22b788 100644
--- a/apt-private/private-cacheset.h
+++ b/apt-private/private-cacheset.h
@@ -32,10 +32,15 @@ struct VersionSortDescriptionLocality
bool operator () (const pkgCache::VerIterator &v_lhs,
const pkgCache::VerIterator &v_rhs)
{
- pkgCache::DescFile *A = v_lhs.TranslatedDescription().FileList();
- pkgCache::DescFile *B = v_rhs.TranslatedDescription().FileList();
- if (A == 0 && B == 0)
- return false;
+ pkgCache::DescFile const *A = NULL;
+ pkgCache::DescFile const *B = NULL;
+ if (v_lhs->DescriptionList != 0)
+ A = v_lhs.TranslatedDescription().FileList();
+ if (v_rhs->DescriptionList != 0)
+ B = v_rhs.TranslatedDescription().FileList();
+
+ if (A == 0 && B == 0)
+ return false;
if (A == 0)
return true;
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 4e18030ab..9944ab002 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -199,10 +199,12 @@ static std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &reco
std::string ShortDescription = "(none)";
if(ver)
{
- pkgCache::DescIterator Desc = ver.TranslatedDescription();
- pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
-
- ShortDescription = parser.ShortDesc();
+ pkgCache::DescIterator const Desc = ver.TranslatedDescription();
+ if (Desc.end() == false)
+ {
+ pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
+ ShortDescription = parser.ShortDesc();
+ }
}
return ShortDescription;
}
@@ -222,11 +224,14 @@ static std::string GetLongDescription(pkgCacheFile &CacheFile, pkgRecords &recor
return EmptyDescription;
pkgCache::DescIterator const Desc = ver.TranslatedDescription();
- pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
- std::string const longdesc = parser.LongDesc();
- if (longdesc.empty() == true)
- return EmptyDescription;
- return SubstVar(longdesc, "\n ", "\n ");
+ if (Desc.end() == false)
+ {
+ pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
+ std::string const longdesc = parser.LongDesc();
+ if (longdesc.empty() == false)
+ return SubstVar(longdesc, "\n ", "\n ");
+ }
+ return EmptyDescription;
}
/*}}}*/
void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
diff --git a/buildlib/environment.mak.in b/buildlib/environment.mak.in
index 0dff02e69..8ea7a05ba 100644
--- a/buildlib/environment.mak.in
+++ b/buildlib/environment.mak.in
@@ -16,6 +16,8 @@ CXXFLAGS+= -Wctor-dtor-privacy -Wdisabled-optimization -Winit-self -Wmissing-inc
#CXXFLAGS+= -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn
# gcc reports currently lots of them at the end of file - unknown reason
CXXFLAGS+= -Wno-deprecated-declarations
+# sanitize options to be enabled for testing
+#CXXFLAGS+= -fsanitize=address -fsanitize=undefined -fno-sanitize=vptr
# a bit too pedantic to be run by default
#CXXFLAGS+= -Wpedantic -Wno-long-long -Wno-vla -Wno-variadic-macros
NUM_PROCS = @NUM_PROCS@
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 303605f70..9c884433c 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1484,6 +1484,7 @@ static bool Search(CommandLine &CmdL)
delete [] PatternMatch;
for (unsigned I = 0; I != NumPatterns; I++)
regfree(&Patterns[I]);
+ delete [] Patterns;
if (ferror(stdout))
return _error->Error("Write to stdout failed");
return true;
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 184b51d23..632c7cfea 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1015,9 +1015,6 @@ static bool DoBuildDep(CommandLine &CmdL)
pkgSourceList *List = Cache.GetSourceList();
// Create the text record parsers
-#if APT_PKG_ABI < 413
- pkgRecords Recs(Cache);
-#endif
pkgSrcRecords SrcRecs(*List);
if (_error->PendingError() == true)
return false;
@@ -1039,6 +1036,7 @@ static bool DoBuildDep(CommandLine &CmdL)
{
string Src;
pkgSrcRecords::Parser *Last = 0;
+ SPtr<pkgSrcRecords::Parser> LastOwner;
// an unpacked debian source tree
using APT::String::Startswith;
@@ -1050,7 +1048,7 @@ static bool DoBuildDep(CommandLine &CmdL)
std::string TypeName = "debian/control File Source Index";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
- Last = Type->CreateSrcPkgParser(*I);
+ LastOwner = Last = Type->CreateSrcPkgParser(*I);
}
// if its a local file (e.g. .dsc) use this
else if (FileExists(*I))
@@ -1061,7 +1059,7 @@ static bool DoBuildDep(CommandLine &CmdL)
string TypeName = flExtension(*I) + " File Source Index";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
- Last = Type->CreateSrcPkgParser(*I);
+ LastOwner = Last = Type->CreateSrcPkgParser(*I);
} else {
// normal case, search the cache for the source file
#if APT_PKG_ABI >= 413
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index 62108f7ca..cf667483c 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -180,7 +180,7 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
// Create a package writer object.
MultiCompress Comp(flCombine(ArchiveDir,PkgFile),
PkgCompress,Permissions);
- PackagesWriter Packages(&Comp.Input, flCombine(CacheDir,BinCacheDB),
+ PackagesWriter Packages(&Comp.Input, TransWriter, flCombine(CacheDir,BinCacheDB),
flCombine(OverrideDir,BinOverride),
flCombine(OverrideDir,ExtraOverride),
Arch);
@@ -193,7 +193,6 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
Packages.DirStrip = ArchiveDir;
Packages.InternalPrefix = flCombine(ArchiveDir,InternalPrefix);
- Packages.TransWriter = TransWriter;
Packages.LongDescription = LongDesc;
Packages.Stats.DeLinkBytes = Stats.DeLinkBytes;
@@ -457,7 +456,7 @@ bool PackageMap::GenContents(Configuration &Setup,
// ---------------------------------------------------------------------
/* This populates the PkgList with all the possible permutations of the
section/arch lists. */
-static void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
+static void LoadTree(vector<PackageMap> &PkgList, std::vector<TranslationWriter*> &TransList, Configuration &Setup)
{
// Load the defaults
string DDir = Setup.Find("TreeDefault::Directory",
@@ -508,16 +507,7 @@ static void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
{NULL, NULL}};
mode_t const Perms = Block.FindI("FileMode", Permissions);
bool const LongDesc = Block.FindB("LongDescription", LongDescription);
- TranslationWriter *TransWriter;
- if (DTrans.empty() == false && LongDesc == false)
- {
- string const TranslationFile = flCombine(Setup.FindDir("Dir::ArchiveDir"),
- SubstVar(Block.Find("Translation", DTrans.c_str()), Vars));
- string const TransCompress = Block.Find("Translation::Compress", TranslationCompress);
- TransWriter = new TranslationWriter(TranslationFile, TransCompress, Perms);
- }
- else
- TransWriter = NULL;
+ TranslationWriter *TransWriter = NULL;
string const Tmp2 = Block.Find("Architectures");
const char *Archs = Tmp2.c_str();
@@ -546,27 +536,34 @@ static void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
Itm.Tag = SubstVar("$(DIST)/$(SECTION)/$(ARCH)",Vars);
Itm.Arch = Arch;
Itm.LongDesc = LongDesc;
- if (TransWriter != NULL)
+ if (TransWriter == NULL && DTrans.empty() == false && LongDesc == false && DTrans != "/dev/null")
{
- TransWriter->IncreaseRefCounter();
- Itm.TransWriter = TransWriter;
+ string const TranslationFile = flCombine(Setup.FindDir("Dir::ArchiveDir"),
+ SubstVar(Block.Find("Translation", DTrans.c_str()), Vars));
+ string const TransCompress = Block.Find("Translation::Compress", TranslationCompress);
+ TransWriter = new TranslationWriter(TranslationFile, TransCompress, Perms);
+ TransList.push_back(TransWriter);
}
+ Itm.TransWriter = TransWriter;
Itm.Contents = SubstVar(Block.Find("Contents",DContents.c_str()),Vars);
Itm.ContentsHead = SubstVar(Block.Find("Contents::Header",DContentsH.c_str()),Vars);
Itm.FLFile = SubstVar(Block.Find("FileList",DFLFile.c_str()),Vars);
Itm.ExtraOverride = SubstVar(Block.Find("ExtraOverride"),Vars);
}
- Itm.GetGeneral(Setup,Block);
+ Itm.GetGeneral(Setup,Block);
PkgList.push_back(Itm);
}
- // we didn't use this TransWriter, so we can release it
- if (TransWriter != NULL && TransWriter->GetRefCounter() == 0)
- delete TransWriter;
}
-
+
Top = Top->Next;
- }
+ }
+}
+ /*}}}*/
+static void UnloadTree(std::vector<TranslationWriter*> const &Trans) /*{{{*/
+{
+ for (std::vector<TranslationWriter*>::const_reverse_iterator T = Trans.rbegin(); T != Trans.rend(); ++T)
+ delete *T;
}
/*}}}*/
// LoadBinDir - Load a 'bindirectory' section from the Generate Config /*{{{*/
@@ -671,7 +668,7 @@ static bool SimpleGenPackages(CommandLine &CmdL)
Override = CmdL.FileList[2];
// Create a package writer object.
- PackagesWriter Packages(NULL, _config->Find("APT::FTPArchive::DB"),
+ PackagesWriter Packages(NULL, NULL, _config->Find("APT::FTPArchive::DB"),
Override, "", _config->Find("APT::FTPArchive::Architecture"));
if (_error->PendingError() == true)
return false;
@@ -844,12 +841,6 @@ static bool DoGeneratePackagesAndSources(Configuration &Setup,
delete [] List;
}
-
- // close the Translation master files
- for (vector<PackageMap>::reverse_iterator I = PkgList.rbegin(); I != PkgList.rend(); ++I)
- if (I->TransWriter != NULL && I->TransWriter->DecreaseRefCounter() == 0)
- delete I->TransWriter;
-
return true;
}
@@ -940,7 +931,8 @@ static bool Generate(CommandLine &CmdL)
return false;
vector<PackageMap> PkgList;
- LoadTree(PkgList,Setup);
+ std::vector<TranslationWriter*> TransList;
+ LoadTree(PkgList, TransList, Setup);
LoadBinDir(PkgList,Setup);
// Sort by cache DB to improve IO locality.
@@ -951,7 +943,10 @@ static bool Generate(CommandLine &CmdL)
if (_config->FindB("APT::FTPArchive::ContentsOnly", false) == false)
{
if(DoGeneratePackagesAndSources(Setup, PkgList, SrcStats, Stats, CmdL) == false)
+ {
+ UnloadTree(TransList);
return false;
+ }
} else {
c1out << "Skipping Packages/Sources generation" << endl;
}
@@ -959,7 +954,10 @@ static bool Generate(CommandLine &CmdL)
// do Contents if needed
if (_config->FindB("APT::FTPArchive::Contents", true) == true)
if (DoGenerateContents(Setup, PkgList, CmdL) == false)
- return false;
+ {
+ UnloadTree(TransList);
+ return false;
+ }
struct timeval NewTime;
gettimeofday(&NewTime,0);
@@ -968,6 +966,7 @@ static bool Generate(CommandLine &CmdL)
c1out << "Done. " << SizeToStr(Stats.Bytes) << "B in " << Stats.Packages
<< " archives. Took " << TimeToStr((long)Delta) << endl;
+ UnloadTree(TransList);
return true;
}
@@ -984,9 +983,12 @@ static bool Clean(CommandLine &CmdL)
Configuration Setup;
if (ReadConfigFile(Setup,CmdL.FileList[1],true) == false)
return false;
+ // we don't need translation creation here
+ Setup.Set("TreeDefault::Translation", "/dev/null");
vector<PackageMap> PkgList;
- LoadTree(PkgList,Setup);
+ std::vector<TranslationWriter*> TransList;
+ LoadTree(PkgList, TransList, Setup);
LoadBinDir(PkgList,Setup);
// Sort by cache DB to improve IO locality.
@@ -1007,14 +1009,13 @@ static bool Clean(CommandLine &CmdL)
_error->DumpErrors();
if (DB_SRC.Clean() == false)
_error->DumpErrors();
-
+
string CacheDB = I->BinCacheDB;
string SrcCacheDB = I->SrcCacheDB;
while(I != PkgList.end() &&
I->BinCacheDB == CacheDB &&
I->SrcCacheDB == SrcCacheDB)
++I;
-
}
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index cc3527ea4..ce6c865f3 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -45,6 +45,7 @@ CacheDB::~CacheDB()
{
ReadyDB();
delete DebFile;
+ CloseFile();
}
// CacheDB::ReadyDB - Ready the DB2 /*{{{*/
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 7cf7e6efc..1bc926d21 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -69,22 +69,29 @@ static void ConfigToDoHashes(unsigned int &DoHashes, std::string const &Conf)
/*}}}*/
// FTWScanner::FTWScanner - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
FTWScanner::FTWScanner(FileFd * const GivenOutput, string const &Arch): Arch(Arch), DoHashes(~0)
{
if (GivenOutput == NULL)
{
Output = new FileFd;
+ OwnsOutput = true;
Output->OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false);
}
else
+ {
Output = GivenOutput;
+ OwnsOutput = false;
+ }
ErrorPrinted = false;
NoLinkAct = !_config->FindB("APT::FTPArchive::DeLinkAct",true);
ConfigToDoHashes(DoHashes, "APT::FTPArchive");
}
/*}}}*/
+FTWScanner::~FTWScanner()
+{
+ if (Output != NULL && OwnsOutput)
+ delete Output;
+}
// FTWScanner::Scanner - FTW Scanner /*{{{*/
// ---------------------------------------------------------------------
/* This is the FTW scanner, it processes each directory element in the
@@ -324,9 +331,10 @@ bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
// PackagesWriter::PackagesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-PackagesWriter::PackagesWriter(FileFd * const GivenOutput, string const &DB,string const &Overrides,string const &ExtOverrides,
- string const &Arch) :
- FTWScanner(GivenOutput, Arch), Db(DB), Stats(Db.Stats), TransWriter(NULL)
+PackagesWriter::PackagesWriter(FileFd * const GivenOutput, TranslationWriter * const transWriter,
+ string const &DB,string const &Overrides,string const &ExtOverrides,
+ string const &Arch) :
+ FTWScanner(GivenOutput, Arch), Db(DB), Stats(Db.Stats), TransWriter(transWriter)
{
SetExts(".deb .udeb");
DeLinkLimit = 0;
@@ -377,7 +385,6 @@ bool FTWScanner::SetExts(string const &Vals)
return true;
}
-
/*}}}*/
// PackagesWriter::DoPackage - Process a single package /*{{{*/
// ---------------------------------------------------------------------
@@ -524,12 +531,16 @@ bool PackagesWriter::DoPackage(string FileName)
return Db.Finish();
}
/*}}}*/
+PackagesWriter::~PackagesWriter() /*{{{*/
+{
+}
+ /*}}}*/
// TranslationWriter::TranslationWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* Create a Translation-Master file for this Packages file */
TranslationWriter::TranslationWriter(string const &File, string const &TransCompress,
- mode_t const &Permissions) : RefCounter(0)
+ mode_t const &Permissions) : Comp(NULL), Output(NULL)
{
if (File.empty() == true)
return;
@@ -568,10 +579,8 @@ bool TranslationWriter::DoPackage(string const &Pkg, string const &Desc,
/* */
TranslationWriter::~TranslationWriter()
{
- if (Comp == NULL)
- return;
-
- delete Comp;
+ if (Comp != NULL)
+ delete Comp;
}
/*}}}*/
diff --git a/ftparchive/writer.h b/ftparchive/writer.h
index 0ba60db5e..b9c1f672a 100644
--- a/ftparchive/writer.h
+++ b/ftparchive/writer.h
@@ -64,6 +64,7 @@ class FTWScanner
public:
FileFd *Output;
+ bool OwnsOutput;
unsigned int DoHashes;
unsigned long DeLinkLimit;
@@ -79,7 +80,7 @@ class FTWScanner
bool SetExts(string const &Vals);
FTWScanner(FileFd * const Output, string const &Arch = string());
- virtual ~FTWScanner() {};
+ virtual ~FTWScanner();
};
class MultiCompress;
@@ -88,17 +89,12 @@ class TranslationWriter
{
MultiCompress *Comp;
std::set<string> Included;
- unsigned short RefCounter;
FileFd *Output;
public:
- void IncreaseRefCounter() { ++RefCounter; };
- unsigned short DecreaseRefCounter() { return (RefCounter == 0) ? 0 : --RefCounter; };
- unsigned short GetRefCounter() const { return RefCounter; };
bool DoPackage(string const &Pkg, string const &Desc, string const &MD5);
TranslationWriter(string const &File, string const &TransCompress, mode_t const &Permissions);
- TranslationWriter() : Comp(NULL), RefCounter(0) {};
~TranslationWriter();
};
@@ -119,18 +115,18 @@ class PackagesWriter : public FTWScanner
string PathPrefix;
string DirStrip;
struct CacheDB::Stats &Stats;
- TranslationWriter *TransWriter;
+ TranslationWriter * const TransWriter;
inline bool ReadOverride(string const &File) {return Over.ReadOverride(File);};
inline bool ReadExtraOverride(string const &File)
{return Over.ReadExtraOverride(File);};
virtual bool DoPackage(string FileName);
- PackagesWriter(FileFd * const Output, string const &DB,
+ PackagesWriter(FileFd * const Output, TranslationWriter * const TransWriter, string const &DB,
string const &Overrides,
string const &ExtOverrides = "",
string const &Arch = "");
- virtual ~PackagesWriter() {};
+ virtual ~PackagesWriter();
};
class ContentsWriter : public FTWScanner
diff --git a/test/integration/framework b/test/integration/framework
index 5d949009f..059cba9fb 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -143,6 +143,7 @@ gdb() {
aptcache) CMD="apt-cache";;
aptmark) CMD="apt-mark";;
apthelper) CMD="apt-helper";;
+ aptftparchive) CMD="apt-ftparchive";;
*) CMD="$1";;
esac
shift
@@ -1415,6 +1416,8 @@ testfailure() {
if expr match "$1" '^apt.*' >/dev/null; then
if grep -q -E ' runtime error: ' "$OUTPUT"; then
msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
+ elif grep -q -E '==ERROR' "$OUTPUT"; then
+ msgfailoutput 'compiler sanitizers reported errors' "$OUTPUT" "$@"
elif ! grep -q -E '^E: ' "$OUTPUT"; then
msgfailoutput "run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@"
else
diff --git a/test/libapt/cdrom_test.cc b/test/libapt/cdrom_test.cc
index 7257eaf1b..b4c51cdb0 100644
--- a/test/libapt/cdrom_test.cc
+++ b/test/libapt/cdrom_test.cc
@@ -91,7 +91,7 @@ TEST(CDROMTest,ReduceSourcelist)
}
TEST(CDROMTest, FindMountPointForDevice)
{
- char * tempfile = NULL;
+ std::string tempfile;
FileFd fd;
createTemporaryFile("mountpoints", fd, &tempfile,
"rootfs / rootfs rw 0 0\n"
@@ -109,7 +109,6 @@ TEST(CDROMTest, FindMountPointForDevice)
EXPECT_EQ("/boot/efi", FindMountPointForDevice("/dev/sda1"));
EXPECT_EQ("/tmp", FindMountPointForDevice("tmpfs"));
- if (tempfile != NULL)
- unlink(tempfile);
- free(tempfile);
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
}
diff --git a/test/libapt/file-helpers.cc b/test/libapt/file-helpers.cc
index 5edb9a9fe..387192868 100644
--- a/test/libapt/file-helpers.cc
+++ b/test/libapt/file-helpers.cc
@@ -53,20 +53,19 @@ void helperCreateLink(std::string const &dir, std::string const &targetname, std
link.append(linkname);
ASSERT_EQ(0, symlink(target.c_str(), link.c_str()));
}
-void helperCreateTemporaryFile(std::string const &id, FileFd &fd, char * * const filename, char const * const content)
+void helperCreateTemporaryFile(std::string const &id, FileFd &fd, std::string * const filename, char const * const content)
{
std::string name("apt-test-");
name.append(id).append(".XXXXXXXX");
char * tempfile = strdup(name.c_str());
+ ASSERT_STRNE(NULL, tempfile);
int tempfile_fd = mkstemp(tempfile);
ASSERT_NE(-1, tempfile_fd);
if (filename != NULL)
*filename = tempfile;
else
- {
unlink(tempfile);
- free(tempfile);
- }
+ free(tempfile);
EXPECT_TRUE(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite));
if (content != NULL)
diff --git a/test/libapt/file-helpers.h b/test/libapt/file-helpers.h
index e8472d503..f639c1cbc 100644
--- a/test/libapt/file-helpers.h
+++ b/test/libapt/file-helpers.h
@@ -24,6 +24,6 @@ void helperCreateDirectory(std::string const &dir, std::string const &name);
void helperCreateLink(std::string const &dir, std::string const &targetname, std::string const &linkname);
#define createTemporaryFile(id, fd, filename, content) \
ASSERT_NO_FATAL_FAILURE(helperCreateTemporaryFile(id, fd, filename, content))
-void helperCreateTemporaryFile(std::string const &id, FileFd &fd, char * * const filename, char const * const content);
+void helperCreateTemporaryFile(std::string const &id, FileFd &fd, std::string * const filename, char const * const content);
#endif
diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc
index 747ab4957..9e6f82213 100644
--- a/test/libapt/sourcelist_test.cc
+++ b/test/libapt/sourcelist_test.cc
@@ -20,7 +20,7 @@ class SourceList : public pkgSourceList {
TEST(SourceListTest,ParseFileDeb822)
{
FileFd fd;
- char * tempfile = NULL;
+ std::string tempfile;
createTemporaryFile("parsefiledeb822", fd, &tempfile,
"Types: deb\n"
"URIs: http://ftp.debian.org/debian\n"
@@ -39,5 +39,6 @@ TEST(SourceListTest,ParseFileDeb822)
EXPECT_EQ(2, sources.ParseFileDeb822(tempfile));
EXPECT_EQ(2, sources.size());
- unlink(tempfile);
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());
}