Niels Thykier, thanks! (Closes: #622805)
// fchmod deals with umask and fchown sets the ownership
if (fchmod(iFd,Itm.Mode) != 0)
// fchmod deals with umask and fchown sets the ownership
if (fchmod(iFd,Itm.Mode) != 0)
- return _error->Errno("fchmod",_("Failed to write file %s"),
- Itm.Name);
+ {
+ _error->Errno("fchmod",_("Failed to write file %s"), Itm.Name);
+ close(iFd);
+ return false;
+ }
if (fchown(iFd,Itm.UID,Itm.GID) != 0 && errno != EPERM)
if (fchown(iFd,Itm.UID,Itm.GID) != 0 && errno != EPERM)
- return _error->Errno("fchown",_("Failed to write file %s"),
- Itm.Name);
+ {
+ return _error->Errno("fchown",_("Failed to write file %s"), Itm.Name);
+ close(iFd);
+ return false;
+ }
break;
if (chdir(CD.c_str()) != 0)
break;
if (chdir(CD.c_str()) != 0)
- return _error->Errno("chdir","Unable to change to %s",CD.c_str());
+ {
+ _error->Errno("chdir","Unable to change to %s", CD.c_str());
+ closedir(D);
+ return false;
+ }
Inodes[I] = Buf.st_ino;
}
Inodes[I] = Buf.st_ino;
}
- if (_error->PendingError() == true)
+ if (_error->PendingError() == true) {
+ delete[] Inodes;
// Look for dups
for (unsigned int I = 0; I != List.size(); I++)
// Look for dups
for (unsigned int I = 0; I != List.size(); I++)
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
msg.str("");
ioprintf(msg, _("Using CD-ROM mount point %s\nMounting CD-ROM\n"),
CDROM.c_str());
msg.str("");
ioprintf(msg, _("Using CD-ROM mount point %s\nMounting CD-ROM\n"),
CDROM.c_str());
return _error->Error("Failed to mount the cdrom.");
// Hash the CD to get an ID
return _error->Error("Failed to mount the cdrom.");
// Hash the CD to get an ID
log->Update(_("Identifying.. "));
log->Update(_("Identifying.. "));
- msg.str("");
- ioprintf(msg, "[%s]\n",ident.c_str());
- log->Update(msg.str());
-
+ if (log != NULL)
+ {
+ msg.str("");
+ ioprintf(msg, "[%s]\n",ident.c_str());
+ log->Update(msg.str());
+ }
// Read the database
Configuration Database;
// Read the database
Configuration Database;
return _error->Error("Unable to read the cdrom database %s",
DFile.c_str());
}
return _error->Error("Unable to read the cdrom database %s",
DFile.c_str());
}
msg.str("");
ioprintf(msg, _("Stored label: %s\n"),
Database.Find("CD::"+ident).c_str());
msg.str("");
ioprintf(msg, _("Stored label: %s\n"),
Database.Find("CD::"+ident).c_str());
- if (_config->FindB("APT::CDROM::NoMount",false) == false) {
- log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+ if (_config->FindB("APT::CDROM::NoMount",false) == false)
+ {
+ if (log != NULL)
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
log->SetTotal(STEP_LAST);
msg.str("");
ioprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str());
log->SetTotal(STEP_LAST);
msg.str("");
ioprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str());
// Unmount the CD and get the user to put in the one they want
if (_config->FindB("APT::CDROM::NoMount",false) == false)
{
// Unmount the CD and get the user to put in the one they want
if (_config->FindB("APT::CDROM::NoMount",false) == false)
{
log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT);
UnmountCdrom(CDROM);
log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT);
UnmountCdrom(CDROM);
log->Update(_("Waiting for disc...\n"), STEP_WAIT);
if(!log->ChangeCdrom()) {
// user aborted
log->Update(_("Waiting for disc...\n"), STEP_WAIT);
if(!log->ChangeCdrom()) {
// user aborted
- log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT);
+ if(log != NULL)
+ log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT);
+
if (MountCdrom(CDROM) == false)
return _error->Error("Failed to mount the cdrom.");
}
// Hash the CD to get an ID
if (MountCdrom(CDROM) == false)
return _error->Error("Failed to mount the cdrom.");
}
// Hash the CD to get an ID
log->Update(_("Identifying.. "), STEP_IDENT);
string ID;
if (IdentCdrom(CDROM,ID) == false)
{
log->Update(_("Identifying.. "), STEP_IDENT);
string ID;
if (IdentCdrom(CDROM,ID) == false)
{
+ if (log != NULL)
+ log->Update("\n");
log->Update("["+ID+"]\n");
log->Update("["+ID+"]\n");
log->Update(_("Scanning disc for index files..\n"),STEP_SCAN);
log->Update(_("Scanning disc for index files..\n"),STEP_SCAN);
// Get the CD structure
vector<string> List;
vector<string> SourceList;
// Get the CD structure
vector<string> List;
vector<string> SourceList;
string InfoDir;
if (FindPackages(CDROM,List,SourceList, SigList,TransList,InfoDir,log) == false)
{
string InfoDir;
if (FindPackages(CDROM,List,SourceList, SigList,TransList,InfoDir,log) == false)
{
+ if (log != NULL)
+ log->Update("\n");
DropRepeats(SourceList,"Sources");
DropRepeats(SigList,"Release.gpg");
DropRepeats(TransList,"");
DropRepeats(SourceList,"Sources");
DropRepeats(SigList,"Release.gpg");
DropRepeats(TransList,"");
msg.str("");
ioprintf(msg, _("Found %zu package indexes, %zu source indexes, "
"%zu translation indexes and %zu signatures\n"),
msg.str("");
ioprintf(msg, _("Found %zu package indexes, %zu source indexes, "
"%zu translation indexes and %zu signatures\n"),
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
msg.str("");
ioprintf(msg, _("Found label '%s'\n"), Name.c_str());
log->Update(msg.str());
msg.str("");
ioprintf(msg, _("Found label '%s'\n"), Name.c_str());
log->Update(msg.str());
if (_config->FindB("APT::CDROM::Rename",false) == true ||
Name.empty() == true)
{
if (_config->FindB("APT::CDROM::Rename",false) == true ||
Name.empty() == true)
{
{
if (_config->FindB("APT::CDROM::NoMount",false) == false)
UnmountCdrom(CDROM);
{
if (_config->FindB("APT::CDROM::NoMount",false) == false)
UnmountCdrom(CDROM);
*J = '_';
Database.Set("CD::" + ID,Name);
*J = '_';
Database.Set("CD::" + ID,Name);
msg.str("");
ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str());
log->Update(msg.str());
msg.str("");
ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str());
log->Update(msg.str());
+ log->Update(_("Copying package lists..."), STEP_COPY);
-
- log->Update(_("Copying package lists..."), STEP_COPY);
// take care of the signatures and copy them if they are ok
// (we do this before PackageCopy as it modifies "List" and "SourceList")
SigVerify SignVerify;
// take care of the signatures and copy them if they are ok
// (we do this before PackageCopy as it modifies "List" and "SourceList")
SigVerify SignVerify;
if (WriteDatabase(Database) == false)
return false;
if (WriteDatabase(Database) == false)
return false;
log->Update(_("Writing new source list\n"), STEP_WRITE);
log->Update(_("Writing new source list\n"), STEP_WRITE);
if (WriteSourceList(Name,List,false) == false ||
WriteSourceList(Name,SourceList,true) == false)
return false;
}
// Print the sourcelist entries
if (WriteSourceList(Name,List,false) == false ||
WriteSourceList(Name,SourceList,true) == false)
return false;
}
// Print the sourcelist entries
log->Update(_("Source list entries for this disc are:\n"));
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
log->Update(_("Source list entries for this disc are:\n"));
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
return _error->Error("Internal error");
}
return _error->Error("Internal error");
}
msg.str("");
msg << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
msg.str("");
msg << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
return _error->Error("Internal error");
}
return _error->Error("Internal error");
}
msg.str("");
msg << "deb-src cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
msg.str("");
msg << "deb-src cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
// Unmount and finish
if (_config->FindB("APT::CDROM::NoMount",false) == false) {
// Unmount and finish
if (_config->FindB("APT::CDROM::NoMount",false) == false) {
- log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+ if (log != NULL)
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
#include <apti18n.h>
#include <sys/wait.h>
#include <apti18n.h>
#include <sys/wait.h>
#include <sys/statvfs.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/statvfs.h>
#include <dirent.h>
#include <fcntl.h>
Hash.Add(Dir->d_name);
};
Hash.Add(Dir->d_name);
};
- if (chdir(StartDir.c_str()) != 0)
- return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
+ if (chdir(StartDir.c_str()) != 0) {
+ _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
+ closedir(D);
+ return false;
+ }
closedir(D);
// Some stats from the fsys
closedir(D);
// Some stats from the fsys
-// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
+// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
string FindMountPointForDevice(const char *devnode)
{
char buf[255];
string FindMountPointForDevice(const char *devnode)
{
char buf[255];
while ( fgets(buf, sizeof(buf), f) != NULL) {
if (strncmp(buf, devnode, strlen(devnode)) == 0) {
if(TokSplitString(' ', buf, out, 10))
while ( fgets(buf, sizeof(buf), f) != NULL) {
if (strncmp(buf, devnode, strlen(devnode)) == 0) {
if(TokSplitString(' ', buf, out, 10))
msgSize = n + 1;
else
msgSize *= 2;
msgSize = n + 1;
else
msgSize *= 2;
msgSize = n + 1;
else
msgSize *= 2;
msgSize = n + 1;
else
msgSize *= 2;
+ delete[] Show;
+ delete[] Flags;
+ delete[] ShapeMap;
string Src;
pkgSrcRecords::Parser *Last = FindSrc(*I,Recs,SrcRecs,Src,*Cache);
string Src;
pkgSrcRecords::Parser *Last = FindSrc(*I,Recs,SrcRecs,Src,*Cache);
+ if (Last == 0) {
+ delete[] Dsc;
return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
string srec = Last->AsStr();
string::size_type pos = srec.find("\nVcs-");
string srec = Last->AsStr();
string::size_type pos = srec.find("\nVcs-");
// Back track
vector<pkgSrcRecords::File> Lst;
// Back track
vector<pkgSrcRecords::File> Lst;
- if (Last->Files(Lst) == false)
+ if (Last->Files(Lst) == false) {
+ delete[] Dsc;
// Load them into the fetcher
for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
// Load them into the fetcher
for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
struct statvfs Buf;
string OutputDir = ".";
if (statvfs(OutputDir.c_str(),&Buf) != 0) {
struct statvfs Buf;
string OutputDir = ".";
if (statvfs(OutputDir.c_str(),&Buf) != 0) {
if (errno == EOVERFLOW)
return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
if (errno == EOVERFLOW)
return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
#if HAVE_STRUCT_STATFS_F_TYPE
|| unsigned(Stat.f_type) != RAMFS_MAGIC
#endif
#if HAVE_STRUCT_STATFS_F_TYPE
|| unsigned(Stat.f_type) != RAMFS_MAGIC
#endif
return _error->Error(_("You don't have enough free space in %s"),
OutputDir.c_str());
return _error->Error(_("You don't have enough free space in %s"),
OutputDir.c_str());
// Number of bytes
if (DebBytes != FetchBytes)
// Number of bytes
if (DebBytes != FetchBytes)
// Run it
if (Fetcher.Run() == pkgAcquire::Failed)
// Run it
if (Fetcher.Run() == pkgAcquire::Failed)
// Print error messages
bool Failed = false;
// Print error messages
bool Failed = false;
Failed = true;
}
if (Failed == true)
Failed = true;
}
if (Failed == true)
return _error->Error(_("Failed to fetch some archives."));
return _error->Error(_("Failed to fetch some archives."));
if (_config->FindB("APT::Get::Download-only",false) == true)
{
c1out << _("Download complete and in download only mode") << endl;
if (_config->FindB("APT::Get::Download-only",false) == true)
{
c1out << _("Download complete and in download only mode") << endl;
apt (0.8.14.1) unstable; urgency=low
[ David Kalnischkies ]
apt (0.8.14.1) unstable; urgency=low
[ David Kalnischkies ]
+ * fix a bunch of cppcheck warnings/errors based on a patch by
+ Niels Thykier, thanks! (Closes: #622805)
* apt-pkg/depcache.cc:
- really include 'rc' packages in the delete count by fixing a
typo which exists since 1999 in the source… (LP: #761175)
* apt-pkg/depcache.cc:
- really include 'rc' packages in the delete count by fixing a
typo which exists since 1999 in the source… (LP: #761175)
- -- David Kalnischkies <kalnischkies@gmail.com> Fri, 15 Apr 2011 23:59:36 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com> Sat, 16 Apr 2011 01:07:44 +0200
apt (0.8.14) unstable; urgency=low
apt (0.8.14) unstable; urgency=low
Itm.Type = pkgDirStream::Item::Directory;
int Fd;
Itm.Type = pkgDirStream::Item::Directory;
int Fd;
- if (Extract.DoItem(Itm,Fd) == false)
+ if (Extract.DoItem(Itm,Fd) == false) {
+ fclose(F);
}
else
if (Deb.ExtractArchive(Extract) == false)
}
else
if (Deb.ExtractArchive(Extract) == false)