Various small leaks here and there. Nothing particularily big, but still
good to fix. Found by the sanitizers while running our testcases.
Reported-By: gcc -fsanitize
Git-Dch: Ignore
26 files changed:
-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;
{
if(MetaIndexParser->IsAlwaysTrusted() || _config->FindB("Acquire::AllowInsecureRepositories") == true)
return true;
/*}}}*/
pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner, /*{{{*/
/*}}}*/
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)
pkgAcquire::Item(Owner), d(NULL), Target(target), TransactionManager(transactionManager)
{
if (TransactionManager != this)
// AcqMetaBase - Constructor /*{{{*/
pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
// AcqMetaBase - Constructor /*{{{*/
pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
std::vector<IndexTarget> const &IndexTargets,
std::vector<IndexTarget> const &IndexTargets,
- IndexTarget const &DataTarget,
- indexRecords * const MetaIndexParser)
+ IndexTarget const &DataTarget)
: pkgAcqTransactionItem(Owner, TransactionManager, DataTarget), d(NULL),
: pkgAcqTransactionItem(Owner, TransactionManager, DataTarget), d(NULL),
- MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL), IndexTargets(IndexTargets),
+ IndexTargets(IndexTargets),
AuthPass(false), IMSHit(false)
{
}
AuthPass(false), IMSHit(false)
{
}
std::string errmsg;
strprintf(errmsg,
// TRANSLATOR: The first %s is the URL of the bad Release file, the second is
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."),
// 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."),
-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) :
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),
d(NULL), ClearsignedTarget(ClearsignedTarget),
- DetachedDataTarget(DetachedDataTarget)
+ DetachedDataTarget(DetachedDataTarget),
+ MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL)
{
// index targets + (worst case:) Release/Release.gpg
ExpectedAdditionalItems = IndexTargets.size() + 2;
{
// index targets + (worst case:) Release/Release.gpg
ExpectedAdditionalItems = IndexTargets.size() + 2;
/*}}}*/
pkgAcqMetaClearSig::~pkgAcqMetaClearSig() /*{{{*/
{
/*}}}*/
pkgAcqMetaClearSig::~pkgAcqMetaClearSig() /*{{{*/
{
+ if (MetaIndexParser != NULL)
+ delete MetaIndexParser;
+ if (LastMetaIndexParser != NULL)
+ delete LastMetaIndexParser;
}
/*}}}*/
// pkgAcqMetaClearSig::Custom600Headers - Insert custom request headers /*{{{*/
}
/*}}}*/
// pkgAcqMetaClearSig::Custom600Headers - Insert custom request headers /*{{{*/
TransactionManager->TransactionStageRemoval(this, GetFinalFilename());
Status = StatDone;
TransactionManager->TransactionStageRemoval(this, GetFinalFilename());
Status = StatDone;
- new pkgAcqMetaIndex(Owner, TransactionManager, DetachedDataTarget, DetachedSigTarget, IndexTargets, TransactionManager->MetaIndexParser);
+ new pkgAcqMetaIndex(Owner, TransactionManager, DetachedDataTarget, DetachedSigTarget, IndexTargets);
/*}}}*/
pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire * const Owner, /*{{{*/
/*}}}*/
pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire * const Owner, /*{{{*/
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &DataTarget,
IndexTarget const &DetachedSigTarget,
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)
DetachedSigTarget(DetachedSigTarget)
{
if(_config->FindB("Debug::Acquire::Transaction", false) == true)
// AcqMetaSig::AcqMetaSig - Constructor /*{{{*/
pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner,
// 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)
IndexTarget const &Target,
pkgAcqMetaIndex * const MetaIndex) :
pkgAcqTransactionItem(Owner, TransactionManager, Target), d(NULL), MetaIndex(MetaIndex)
// AcqBaseIndex - Constructor /*{{{*/
pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
// AcqBaseIndex - Constructor /*{{{*/
pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target)
: pkgAcqTransactionItem(Owner, TransactionManager, Target), d(NULL)
{
IndexTarget const &Target)
: pkgAcqTransactionItem(Owner, TransactionManager, Target), d(NULL)
{
* the original packages file
*/
pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner,
* the original packages file
*/
pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner,
- pkgAcqMetaBase * const TransactionManager,
+ pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target)
IndexTarget const &Target)
- : pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL)
+ : pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL), diffs(NULL)
{
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
{
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, available_patches);
else
{
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,
for(size_t i = 0; i < available_patches.size(); ++i)
(*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, TransactionManager,
Target,
-pkgAcqDiffIndex::~pkgAcqDiffIndex() {}
+pkgAcqDiffIndex::~pkgAcqDiffIndex()
+{
+ if (diffs != NULL)
+ delete diffs;
+}
// AcqIndexDiffs::AcqIndexDiffs - Constructor /*{{{*/
// ---------------------------------------------------------------------
// AcqIndexDiffs::AcqIndexDiffs - Constructor /*{{{*/
// ---------------------------------------------------------------------
* for each diff and the index
*/
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
* 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),
IndexTarget const &Target,
vector<DiffInfo> const &diffs)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL),
// AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/
pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
// 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)
IndexTarget const &Target,
DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
// AcqIndex::AcqIndex - Constructor /*{{{*/
pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner,
// 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)
{
IndexTarget const &Target)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL), Stage(STAGE_DOWNLOAD)
{
class indexRecords;
class pkgRecords;
class pkgSourceList;
class indexRecords;
class pkgRecords;
class pkgSourceList;
+class pkgAcqMetaClearSig;
+class pkgAcqIndexMergeDiffs;
class pkgAcquire::Item : public WeakPointable /*{{{*/
/** \brief Represents the process by which a pkgAcquire object should
class pkgAcquire::Item : public WeakPointable /*{{{*/
/** \brief Represents the process by which a pkgAcquire object should
void * const d;
friend class pkgAcqMetaBase;
void * const d;
friend class pkgAcqMetaBase;
+ friend class pkgAcqMetaClearSig;
};
/*}}}*/
class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
};
/*}}}*/
class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
std::string PartialFile;
/** \brief TransactionManager */
std::string PartialFile;
/** \brief TransactionManager */
- pkgAcqMetaBase * const TransactionManager;
+ pkgAcqMetaClearSig * const TransactionManager;
enum TransactionStates {
TransactionCommit,
enum TransactionStates {
TransactionCommit,
virtual bool HashesRequired() const;
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;
virtual ~pkgAcqTransactionItem();
friend class pkgAcqMetaBase;
+ friend class pkgAcqMetaClearSig;
};
/*}}}*/
class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
};
/*}}}*/
class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
protected:
std::vector<pkgAcqTransactionItem*> Transaction;
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.
*/
/** \brief The index files which should be looked up in the meta-index
* and then downloaded.
*/
/** \brief Get the full pathname of the final file for the current URI */
virtual std::string GetFinalFilename() const;
/** \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,
std::vector<IndexTarget> const &IndexTargets,
- IndexTarget const &DataTarget,
- indexRecords* const MetaIndexParser);
+ IndexTarget const &DataTarget);
virtual ~pkgAcqMetaBase();
};
/*}}}*/
virtual ~pkgAcqMetaBase();
};
/*}}}*/
virtual void Finished();
/** \brief Create a new pkgAcqMetaIndex. */
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,
IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
- std::vector<IndexTarget> const &IndexTargets, indexRecords * const MetaIndexParser);
+ std::vector<IndexTarget> const &IndexTargets);
virtual ~pkgAcqMetaIndex();
friend class pkgAcqMetaSig;
virtual ~pkgAcqMetaIndex();
friend class pkgAcqMetaSig;
pkgAcquire::MethodConfig const * const Cnf);
/** \brief Create a new pkgAcqMetaSig. */
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();
};
/*}}}*/
virtual ~pkgAcqMetaSig();
};
/*}}}*/
IndexTarget const ClearsignedTarget;
IndexTarget const DetachedDataTarget;
IndexTarget const ClearsignedTarget;
IndexTarget const DetachedDataTarget;
+ 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,
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,
/** \brief Get the full pathname of the final file for the current URI */
virtual std::string GetFinalFilename() const;
/** \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();
};
IndexTarget const &Target);
virtual ~pkgAcqBaseIndex();
};
class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
{
void * const d;
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. */
protected:
/** \brief If \b true, debugging information will be written to std::clog. */
*
* \param ShortDesc A short description of the list file to download.
*/
*
* \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:
IndexTarget const &Target);
virtual ~pkgAcqDiffIndex();
private:
* \param allPatches contains all related items so that each item can
* check if it was the last one to complete the download step
*/
* \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();
IndexTarget const &Target, DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
virtual ~pkgAcqIndexMergeDiffs();
* should be ordered so that each diff appears before any diff
* that depends on it.
*/
* 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();
IndexTarget const &Target,
std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
virtual ~pkgAcqIndexDiffs();
virtual std::string DescURI() const {return Desc.URI;};
virtual std::string GetMetaKey() const;
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();
IndexTarget const &Target);
virtual ~pkgAcqIndex();
unlink(Owner->DestFile.c_str());
if (link(filename.c_str(), Owner->DestFile.c_str()) != 0)
{
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
// 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
if (_config->FindB("pkgCacheFile::Generate", true) == false)
{
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;
Cache = new pkgCache(Map);
if (_error->PendingError() == true)
return false;
fclose(f);
// unescape the \0XXX chars in the path
string mount_point = out[1];
fclose(f);
// unescape the \0XXX chars in the path
string mount_point = out[1];
return DeEscapeString(mount_point);
}
fclose(f);
return DeEscapeString(mount_point);
}
fclose(f);
// all the rest is whitespace, unsigned garbage or additional message blocks we ignore
}
fclose(in);
// 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());
if (found_signature == true)
return _error->Error("Signature in file %s wasn't closed", InFile.c_str());
// 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>())
// 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
APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
targets, iR);
#undef APT_TARGET
// RecordParser::Jump - Jump to a specific record /*{{{*/
bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
{
// 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)
{
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);
}
/*}}}*/
return Tags.Jump(Section,Desc->Offset);
}
/*}}}*/
a != Args.end(); ++a)
clog << *a << ' ';
clog << endl;
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);
continue;
}
Args.push_back(NULL);
-indexRecords::~indexRecords() {}
+indexRecords::~indexRecords() {
+ for (std::map<std::string, checkSum*>::const_iterator S = Entries.begin(); S != Entries.end(); ++S)
+ delete S->second;
+}
public:
void Reset(FileFd * const pFd, unsigned long long const pSize)
{
public:
void Reset(FileFd * const pFd, unsigned long long const pSize)
{
+ if (Buffer != NULL)
+ free(Buffer);
Start = NULL;
End = NULL;
Done = false;
Start = NULL;
End = NULL;
Done = false;
- pkgTagFilePrivate(FileFd * const pFd, unsigned long long const Size)
+ pkgTagFilePrivate(FileFd * const pFd, unsigned long long const Size) : Buffer(NULL)
bool Done;
unsigned long long iOffset;
unsigned long long Size;
bool Done;
unsigned long long iOffset;
unsigned long long Size;
+
+ ~pkgTagFilePrivate()
+ {
+ if (Buffer != NULL)
+ free(Buffer);
+ }
};
class pkgTagSectionPrivate
};
class pkgTagSectionPrivate
/* */
pkgTagFile::~pkgTagFile()
{
/* */
pkgTagFile::~pkgTagFile()
{
*
* @param File to write the section to
* @param Order in which tags should appear in the file
*
* @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;
* @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;
bool operator () (const pkgCache::VerIterator &v_lhs,
const pkgCache::VerIterator &v_rhs)
{
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;
std::string ShortDescription = "(none)";
if(ver)
{
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;
}
}
return ShortDescription;
}
return EmptyDescription;
pkgCache::DescIterator const Desc = ver.TranslatedDescription();
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, /*{{{*/
}
/*}}}*/
void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
#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
#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@
# a bit too pedantic to be run by default
#CXXFLAGS+= -Wpedantic -Wno-long-long -Wno-vla -Wno-variadic-macros
NUM_PROCS = @NUM_PROCS@
delete [] PatternMatch;
for (unsigned I = 0; I != NumPatterns; I++)
regfree(&Patterns[I]);
delete [] PatternMatch;
for (unsigned I = 0; I != NumPatterns; I++)
regfree(&Patterns[I]);
if (ferror(stdout))
return _error->Error("Write to stdout failed");
return true;
if (ferror(stdout))
return _error->Error("Write to stdout failed");
return true;
pkgSourceList *List = Cache.GetSourceList();
// Create the text record parsers
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;
pkgSrcRecords SrcRecs(*List);
if (_error->PendingError() == true)
return false;
{
string Src;
pkgSrcRecords::Parser *Last = 0;
{
string Src;
pkgSrcRecords::Parser *Last = 0;
+ SPtr<pkgSrcRecords::Parser> LastOwner;
// an unpacked debian source tree
using APT::String::Startswith;
// an unpacked debian source tree
using APT::String::Startswith;
std::string TypeName = "debian/control File Source Index";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
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))
}
// if its a local file (e.g. .dsc) use this
else if (FileExists(*I))
string TypeName = flExtension(*I) + " File Source Index";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
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
} else {
// normal case, search the cache for the source file
#if APT_PKG_ABI >= 413
// Create a package writer object.
MultiCompress Comp(flCombine(ArchiveDir,PkgFile),
PkgCompress,Permissions);
// 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);
flCombine(OverrideDir,BinOverride),
flCombine(OverrideDir,ExtraOverride),
Arch);
Packages.DirStrip = ArchiveDir;
Packages.InternalPrefix = flCombine(ArchiveDir,InternalPrefix);
Packages.DirStrip = ArchiveDir;
Packages.InternalPrefix = flCombine(ArchiveDir,InternalPrefix);
- Packages.TransWriter = TransWriter;
Packages.LongDescription = LongDesc;
Packages.Stats.DeLinkBytes = Stats.DeLinkBytes;
Packages.LongDescription = LongDesc;
Packages.Stats.DeLinkBytes = Stats.DeLinkBytes;
// ---------------------------------------------------------------------
/* This populates the PkgList with all the possible permutations of the
section/arch lists. */
// ---------------------------------------------------------------------
/* 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",
{
// Load the defaults
string DDir = Setup.Find("TreeDefault::Directory",
{NULL, NULL}};
mode_t const Perms = Block.FindI("FileMode", Permissions);
bool const LongDesc = Block.FindB("LongDescription", LongDescription);
{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();
string const Tmp2 = Block.Find("Architectures");
const char *Archs = Tmp2.c_str();
Itm.Tag = SubstVar("$(DIST)/$(SECTION)/$(ARCH)",Vars);
Itm.Arch = Arch;
Itm.LongDesc = LongDesc;
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.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);
}
PkgList.push_back(Itm);
}
- // we didn't use this TransWriter, so we can release it
- if (TransWriter != NULL && TransWriter->GetRefCounter() == 0)
- delete TransWriter;
+ }
+}
+ /*}}}*/
+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 /*{{{*/
}
/*}}}*/
// LoadBinDir - Load a 'bindirectory' section from the Generate Config /*{{{*/
Override = CmdL.FileList[2];
// Create a package writer object.
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;
Override, "", _config->Find("APT::FTPArchive::Architecture"));
if (_error->PendingError() == true)
return false;
-
- // 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 false;
vector<PackageMap> PkgList;
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.
LoadBinDir(PkgList,Setup);
// Sort by cache DB to improve IO locality.
if (_config->FindB("APT::FTPArchive::ContentsOnly", false) == false)
{
if(DoGeneratePackagesAndSources(Setup, PkgList, SrcStats, Stats, CmdL) == false)
if (_config->FindB("APT::FTPArchive::ContentsOnly", false) == false)
{
if(DoGeneratePackagesAndSources(Setup, PkgList, SrcStats, Stats, CmdL) == false)
+ {
+ UnloadTree(TransList);
} else {
c1out << "Skipping Packages/Sources generation" << endl;
}
} else {
c1out << "Skipping Packages/Sources generation" << endl;
}
// do Contents if needed
if (_config->FindB("APT::FTPArchive::Contents", true) == true)
if (DoGenerateContents(Setup, PkgList, CmdL) == false)
// do Contents if needed
if (_config->FindB("APT::FTPArchive::Contents", true) == true)
if (DoGenerateContents(Setup, PkgList, CmdL) == false)
+ {
+ UnloadTree(TransList);
+ return false;
+ }
struct timeval NewTime;
gettimeofday(&NewTime,0);
struct timeval NewTime;
gettimeofday(&NewTime,0);
c1out << "Done. " << SizeToStr(Stats.Bytes) << "B in " << Stats.Packages
<< " archives. Took " << TimeToStr((long)Delta) << endl;
c1out << "Done. " << SizeToStr(Stats.Bytes) << "B in " << Stats.Packages
<< " archives. Took " << TimeToStr((long)Delta) << endl;
Configuration Setup;
if (ReadConfigFile(Setup,CmdL.FileList[1],true) == false)
return false;
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;
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.
LoadBinDir(PkgList,Setup);
// Sort by cache DB to improve IO locality.
_error->DumpErrors();
if (DB_SRC.Clean() == false)
_error->DumpErrors();
_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;
string CacheDB = I->BinCacheDB;
string SrcCacheDB = I->SrcCacheDB;
while(I != PkgList.end() &&
I->BinCacheDB == CacheDB &&
I->SrcCacheDB == SrcCacheDB)
++I;
{
ReadyDB();
delete DebFile;
{
ReadyDB();
delete DebFile;
}
// CacheDB::ReadyDB - Ready the DB2 /*{{{*/
}
// CacheDB::ReadyDB - Ready the DB2 /*{{{*/
/*}}}*/
// FTWScanner::FTWScanner - Constructor /*{{{*/
/*}}}*/
// FTWScanner::FTWScanner - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
FTWScanner::FTWScanner(FileFd * const GivenOutput, string const &Arch): Arch(Arch), DoHashes(~0)
{
if (GivenOutput == NULL)
{
Output = new FileFd;
FTWScanner::FTWScanner(FileFd * const GivenOutput, string const &Arch): Arch(Arch), DoHashes(~0)
{
if (GivenOutput == NULL)
{
Output = new FileFd;
Output->OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false);
}
else
Output->OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false);
}
else
+ OwnsOutput = false;
+ }
ErrorPrinted = false;
NoLinkAct = !_config->FindB("APT::FTPArchive::DeLinkAct",true);
ConfigToDoHashes(DoHashes, "APT::FTPArchive");
}
/*}}}*/
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
// FTWScanner::Scanner - FTW Scanner /*{{{*/
// ---------------------------------------------------------------------
/* This is the FTW scanner, it processes each directory element in the
// PackagesWriter::PackagesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
// 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;
{
SetExts(".deb .udeb");
DeLinkLimit = 0;
/*}}}*/
// PackagesWriter::DoPackage - Process a single package /*{{{*/
// ---------------------------------------------------------------------
/*}}}*/
// PackagesWriter::DoPackage - Process a single package /*{{{*/
// ---------------------------------------------------------------------
return Db.Finish();
}
/*}}}*/
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,
// 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;
{
if (File.empty() == true)
return;
/* */
TranslationWriter::~TranslationWriter()
{
/* */
TranslationWriter::~TranslationWriter()
{
- if (Comp == NULL)
- return;
-
- delete Comp;
+ if (Comp != NULL)
+ delete Comp;
unsigned int DoHashes;
unsigned long DeLinkLimit;
unsigned int DoHashes;
unsigned long DeLinkLimit;
bool SetExts(string const &Vals);
FTWScanner(FileFd * const Output, string const &Arch = string());
bool SetExts(string const &Vals);
FTWScanner(FileFd * const Output, string const &Arch = string());
- virtual ~FTWScanner() {};
{
MultiCompress *Comp;
std::set<string> Included;
{
MultiCompress *Comp;
std::set<string> Included;
- unsigned short RefCounter;
- 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);
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) {};
string PathPrefix;
string DirStrip;
struct CacheDB::Stats &Stats;
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);
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 = "");
string const &Overrides,
string const &ExtOverrides = "",
string const &Arch = "");
- virtual ~PackagesWriter() {};
+ virtual ~PackagesWriter();
};
class ContentsWriter : public FTWScanner
};
class ContentsWriter : public FTWScanner
aptcache) CMD="apt-cache";;
aptmark) CMD="apt-mark";;
apthelper) CMD="apt-helper";;
aptcache) CMD="apt-cache";;
aptmark) CMD="apt-mark";;
apthelper) CMD="apt-helper";;
+ aptftparchive) CMD="apt-ftparchive";;
if expr match "$1" '^apt.*' >/dev/null; then
if grep -q -E ' runtime error: ' "$OUTPUT"; then
msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
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
elif ! grep -q -E '^E: ' "$OUTPUT"; then
msgfailoutput "run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@"
else
}
TEST(CDROMTest, FindMountPointForDevice)
{
}
TEST(CDROMTest, FindMountPointForDevice)
{
- char * tempfile = NULL;
FileFd fd;
createTemporaryFile("mountpoints", fd, &tempfile,
"rootfs / rootfs rw 0 0\n"
FileFd fd;
createTemporaryFile("mountpoints", fd, &tempfile,
"rootfs / rootfs rw 0 0\n"
EXPECT_EQ("/boot/efi", FindMountPointForDevice("/dev/sda1"));
EXPECT_EQ("/tmp", FindMountPointForDevice("tmpfs"));
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());
link.append(linkname);
ASSERT_EQ(0, symlink(target.c_str(), link.c_str()));
}
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());
{
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
int tempfile_fd = mkstemp(tempfile);
ASSERT_NE(-1, tempfile_fd);
if (filename != NULL)
*filename = tempfile;
else
EXPECT_TRUE(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite));
if (content != NULL)
EXPECT_TRUE(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite));
if (content != NULL)
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 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);
TEST(SourceListTest,ParseFileDeb822)
{
FileFd fd;
TEST(SourceListTest,ParseFileDeb822)
{
FileFd fd;
- char * tempfile = NULL;
createTemporaryFile("parsefiledeb822", fd, &tempfile,
"Types: deb\n"
"URIs: http://ftp.debian.org/debian\n"
createTemporaryFile("parsefiledeb822", fd, &tempfile,
"Types: deb\n"
"URIs: http://ftp.debian.org/debian\n"
EXPECT_EQ(2, sources.ParseFileDeb822(tempfile));
EXPECT_EQ(2, sources.size());
EXPECT_EQ(2, sources.ParseFileDeb822(tempfile));
EXPECT_EQ(2, sources.size());
+ if (tempfile.empty() == false)
+ unlink(tempfile.c_str());