diff options
author | Michael Vogt <mvo@debian.org> | 2013-07-28 09:25:57 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-07-28 09:25:57 +0200 |
commit | 0c33605d981ceb78a4761e39043dc79ef9a571b2 (patch) | |
tree | 83fa22dda53f0abccd7b9cf7376af8553c559068 | |
parent | 402c0d19a0c6668d7710b2b48561eb3059a04584 (diff) | |
parent | 163dc55bd6891008adcdf6d683a94e890a00f8c7 (diff) |
Merge remote-tracking branch 'mvo/bugfix/coverity' into debian/sid
-rw-r--r-- | .travis.yml | 5 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | apt-pkg/aptconfiguration.cc | 4 | ||||
-rw-r--r-- | apt-pkg/cacheset.h | 1 | ||||
-rw-r--r-- | apt-pkg/contrib/cdromutl.cc | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/configuration.cc | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 17 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 6 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.cc | 1 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 1 | ||||
-rw-r--r-- | apt-pkg/indexcopy.cc | 5 | ||||
-rw-r--r-- | cmdline/apt-get.cc | 10 | ||||
-rw-r--r-- | cmdline/apt-mark.cc | 4 | ||||
-rw-r--r-- | methods/ftp.cc | 1 | ||||
-rw-r--r-- | methods/gpgv.cc | 1 | ||||
-rw-r--r-- | methods/http.cc | 2 | ||||
-rw-r--r-- | methods/rsh.cc | 2 |
17 files changed, 41 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..56536837f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: cpp +before_install: + - sudo apt-get update -q + - sudo apt-get install -q dpkg-dev debhelper libdb-dev gettext libcurl4-gnutls-dev zlib1g-dev libbz2-dev xsltproc docbook-xsl docbook-xml po4a autotools-dev autoconf automake doxygen debiandoc-sgml +script: make && make test && test/integration/run-tests @@ -19,7 +19,7 @@ all headers library clean veryclean binary program doc manpages debiandoc test u $(MAKE) -C dselect $@ $(MAKE) -C doc $@ $(MAKE) -C po $@ - $(MAKE) -C test $@ + $(MAKE) -C test $@ all headers library clean veryclean binary program doc manpages debiandoc test update-po: startup dirs diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 37c846582..e32e553a4 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -388,12 +388,12 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache if (dpkgMultiArch == 0) { close(external[0]); std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory"); - if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0) - _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --print-foreign-architectures", chrootDir.c_str()); int const nullfd = open("/dev/null", O_RDONLY); dup2(nullfd, STDIN_FILENO); dup2(external[1], STDOUT_FILENO); dup2(nullfd, STDERR_FILENO); + if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0) + _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --print-foreign-architectures", chrootDir.c_str()); execvp(Args[0], (char**) &Args[0]); _error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!"); _exit(100); diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 2a45910ba..d7328d705 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -11,7 +11,6 @@ // Include Files /*{{{*/ #include <iostream> #include <fstream> -#include <list> #include <map> #include <set> #include <list> diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 187f6bd59..afa01a562 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -122,8 +122,9 @@ bool MountCdrom(string Path, string DeviceName) if (Child == 0) { // Make all the fds /dev/null + int null_fd = open("/dev/null",O_RDWR); for (int I = 0; I != 3; I++) - dup2(open("/dev/null",O_RDWR),I); + dup2(null_fd, I); if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true) { diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 808a708a1..376617401 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -811,7 +811,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio // Go down a level if (TermChar == '{') { - if (StackPos <= 100) + if (StackPos < sizeof(Stack)/sizeof(std::string)) Stack[StackPos++] = ParentTag; /* Make sectional tags incorperate the section into the diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 5debb4f92..f24df65fc 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -244,17 +244,20 @@ int GetLock(string File,bool Errors) fl.l_len = 0; if (fcntl(FD,F_SETLK,&fl) == -1) { + // always close to not leak resources + int Tmp = errno; + close(FD); + errno = Tmp; + if (errno == ENOLCK) { _error->Warning(_("Not using locking for nfs mounted lock file %s"),File.c_str()); return dup(0); // Need something for the caller to close - } + } + if (Errors == true) _error->Errno("open",_("Could not get lock %s"),File.c_str()); - int Tmp = errno; - close(FD); - errno = Tmp; return -1; } @@ -1218,11 +1221,9 @@ FileFd::~FileFd() { Close(); if (d != NULL) - { d->CloseDown(FileName); - delete d; - d = NULL; - } + delete d; + d = NULL; } /*}}}*/ // FileFd::Read - Read a bit of the file /*{{{*/ diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index d0e74d8c5..df02c3499 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1233,12 +1233,12 @@ char *safe_snprintf(char *Buffer,char *End,const char *Format,...) va_list args; int Did; - va_start(args,Format); - if (End <= Buffer) return End; - + va_start(args,Format); Did = vsnprintf(Buffer,End - Buffer,Format,args); + va_end(args); + if (Did < 0 || Buffer + Did > End) return End; return Buffer + Did; diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 7dd5ab2bf..b597b6f3c 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -238,6 +238,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, HashString()); } + delete targets; // this is normally created in pkgAcqMetaSig, but if we run // in --print-uris mode, we add it here diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d8fc8ef68..b0bd6b184 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -134,6 +134,7 @@ static void dpkgChrootDirectory() std::cerr << "Chrooting into " << chrootDir << std::endl; if (chroot(chrootDir.c_str()) != 0) _exit(100); + chdir("/"); } /*}}}*/ diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 1d61b974d..7694cb1dd 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -106,9 +106,9 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List, } else { Target.Open(TargetF,FileFd::WriteAtomic); } - FILE *TargetFl = fdopen(dup(Target.Fd()),"w"); if (_error->PendingError() == true) return false; + FILE *TargetFl = fdopen(dup(Target.Fd()),"w"); if (TargetFl == 0) return _error->Errno("fdopen","Failed to reopen fd"); @@ -601,6 +601,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList, (useInRelease ? inrelease.c_str() : releasegpg.c_str())); // something went wrong, don't copy the Release.gpg // FIXME: delete any existing gpg file? + delete MetaIndex; continue; } @@ -714,9 +715,9 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ } else { Target.Open(TargetF,FileFd::WriteAtomic); } - FILE *TargetFl = fdopen(dup(Target.Fd()),"w"); if (_error->PendingError() == true) return false; + FILE *TargetFl = fdopen(dup(Target.Fd()),"w"); if (TargetFl == 0) return _error->Errno("fdopen","Failed to reopen fd"); diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 85ed80a95..73b396795 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2290,9 +2290,10 @@ bool DoClean(CommandLine &CmdL) FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - Lock.Fd(GetLock(archivedir + "lock")); - if (_error->PendingError() == true) + int lock_fd = GetLock(archivedir + "lock"); + if (lock_fd < 0) return _error->Error(_("Unable to lock the download directory")); + Lock.Fd(lock_fd); } pkgAcquire Fetcher; @@ -2326,9 +2327,10 @@ bool DoAutoClean(CommandLine &CmdL) FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock")); - if (_error->PendingError() == true) + int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"); + if (lock_fd < 0) return _error->Error(_("Unable to lock the download directory")); + Lock.Fd(lock_fd); } CacheFile Cache; diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index c5b7ca496..4c0fc2893 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -202,13 +202,13 @@ bool DoHold(CommandLine &CmdL) if (dpkgAssertMultiArch == 0) { std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory"); - if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0) - _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --assert-multi-arch", chrootDir.c_str()); // redirect everything to the ultimate sink as we only need the exit-status int const nullfd = open("/dev/null", O_RDONLY); dup2(nullfd, STDIN_FILENO); dup2(nullfd, STDOUT_FILENO); dup2(nullfd, STDERR_FILENO); + if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0) + _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --assert-multi-arch", chrootDir.c_str()); execvp(Args[0], (char**) &Args[0]); _error->WarningE("dpkgGo", "Can't detect if dpkg supports multi-arch!"); _exit(2); diff --git a/methods/ftp.cc b/methods/ftp.cc index d55ac1224..979adca62 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -436,6 +436,7 @@ bool FTPConn::WriteMsg(unsigned int &Ret,string &Text,const char *Fmt,...) char S[400]; vsnprintf(S,sizeof(S) - 4,Fmt,args); strcat(S,"\r\n"); + va_end(args); if (Debug == true) cerr << "-> '" << QuoteString(S,"") << "'" << endl; diff --git a/methods/gpgv.cc b/methods/gpgv.cc index fe8bac6c9..ea8a26fd4 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -152,6 +152,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, } } fclose(pipein); + free(buffer); int status; waitpid(pid, &status, 0); diff --git a/methods/http.cc b/methods/http.cc index 82456d78b..278ddb290 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -1400,7 +1400,7 @@ bool HttpMethod::AutoDetectProxy() char buf[512]; int InFd = Pipes[0]; close(Pipes[1]); - int res = read(InFd, buf, sizeof(buf)); + int res = read(InFd, buf, sizeof(buf)-1); ExecWait(Process, "ProxyAutoDetect", true); if (res < 0) diff --git a/methods/rsh.cc b/methods/rsh.cc index fb3782314..d76dca6ef 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -218,6 +218,8 @@ bool RSHConn::WriteMsg(std::string &Text,bool Sync,const char *Fmt,...) // sprintf the description char S[512]; vsnprintf(S,sizeof(S) - 4,Fmt,args); + va_end(args); + if (Sync == true) strcat(S," 2> /dev/null || echo\n"); else |