From 267275c59cc35704789a228c6e9b1464c4cabd74 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Jul 2013 15:00:53 +0200 Subject: remove double list include --- apt-pkg/cacheset.h | 1 - 1 file changed, 1 deletion(-) 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 #include -#include #include #include #include -- cgit v1.2.3 From 96ab3c6f62becde2fc67b81c65eef2881856fd22 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:14:31 +0200 Subject: always "delete d" in FileFd::~FileFd to coverity happy --- apt-pkg/contrib/fileutl.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 0f88923cf..edf612810 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1218,11 +1218,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 /*{{{*/ -- cgit v1.2.3 From 26d5b68a008cfedec113ebdde782c3d18478a5b4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:14:59 +0200 Subject: fix off-by-one error and do not use magic constant of 100 when checking StackPost --- apt-pkg/contrib/configuration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From c104200045ef19f5ee061c4a00b468482ac65dc4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:16:31 +0200 Subject: =?UTF-8?q?fix=20off-by-one=20error=20in=20HttpMethod::=E2=80=8BAu?= =?UTF-8?q?toDetectProxy()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- methods/http.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/methods/http.cc b/methods/http.cc index db1085a2d..ec5b1ff52 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -1401,7 +1401,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) -- cgit v1.2.3 From fe0036dd7e3bbd808fa526e2e142fdb89105caae Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:22:43 +0200 Subject: rework the code in cdromutl.cc to make coverity (more) happy --- apt-pkg/contrib/cdromutl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { -- cgit v1.2.3 From 3d165906327828990bec2c58a3c1f4ee77467523 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:26:11 +0200 Subject: fix resource leak (thanks coverity) --- apt-pkg/contrib/fileutl.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index edf612810..398830ff5 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -244,17 +244,21 @@ 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; } -- cgit v1.2.3 From db0e2486a18332154b6c8ac6a6f0f74f40b40a05 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:30:59 +0200 Subject: add .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..df16858be --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: cpp +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq 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: test/integration/run-tests -- cgit v1.2.3 From a80a03448fe11f8ea3fd4a8c525fc413c9ce9037 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:36:23 +0200 Subject: call fdopen() after FileFd was checked --- apt-pkg/indexcopy.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 1d61b974d..a2adb2d00 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -714,9 +714,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"); -- cgit v1.2.3 From 60fc4f21783fddaae481494f99ec157e08a9bfdb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:41:03 +0200 Subject: apt-pkg/indexcopy.cc: check for pending errors before calling fdopen() --- apt-pkg/indexcopy.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index a2adb2d00..4920efff8 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -106,9 +106,9 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &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"); -- cgit v1.2.3 From a9d6b0ad873fdf38e7a7077fd1f07289ad66d45a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:45:53 +0200 Subject: fix resource leak when verification fails --- apt-pkg/indexcopy.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 4920efff8..7694cb1dd 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -601,6 +601,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &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; } -- cgit v1.2.3 From 6612c86ef3d8f2b8bccc6212791996ab9e053082 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:46:08 +0200 Subject: delete targets data --- apt-pkg/deb/debmetaindex.cc | 1 + 1 file changed, 1 insertion(+) 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 -- cgit v1.2.3 From de24f8ce508edd02690947d8dff7f0a4090a67fe Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:55:02 +0200 Subject: fix potential GetLock() fd leak --- cmdline/apt-get.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; -- cgit v1.2.3 From 1b7bf822ad9504f6d01cd4422d830e8815143912 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 20:55:18 +0200 Subject: add missing "free(buffer) for allocated buffer --- apt-pkg/contrib/fileutl.cc | 1 - methods/gpgv.cc | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 398830ff5..0b6e07f75 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -251,7 +251,6 @@ int GetLock(string File,bool Errors) 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 } 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); -- cgit v1.2.3 From 079706b449d359366bf9342de1b0897eb0dbd2b9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 25 Jul 2013 21:06:40 +0200 Subject: fix travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df16858be..392a2f3ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp before_install: - sudo apt-get update -qq - - sudo apt-get install -qq 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 + - sudo apt-get install -qq 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: test/integration/run-tests -- cgit v1.2.3 From 49e1672884bf8d50713812bdd4eca26ab2076711 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 07:10:21 +0200 Subject: make setup in travis.yml a bit more verbose --- .travis.yml | 4 ++-- Makefile | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 392a2f3ea..ec1e1de77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq 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 + - 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: test/integration/run-tests diff --git a/Makefile b/Makefile index 98b6d337a..ad51da3ef 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,6 @@ all headers library clean veryclean binary program doc manpages debiandoc test u $(MAKE) -C cmdline $@ $(MAKE) -C ftparchive $@ $(MAKE) -C dselect $@ - $(MAKE) -C doc $@ - $(MAKE) -C po $@ - $(MAKE) -C test $@ all headers library clean veryclean binary program doc manpages debiandoc test update-po: startup dirs -- cgit v1.2.3 From 8672ae9d47780e288ad97816670b78ece399074d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 07:20:23 +0200 Subject: build tree first --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ec1e1de77..c1b1e120c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ 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: test/integration/run-tests +script: make && test/integration/run-tests -- cgit v1.2.3 From 534454d4f806248dd89fadd0c411aadc55272ec3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 11:22:30 +0200 Subject: add missing "make test" for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1b1e120c..56536837f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ 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 && test/integration/run-tests +script: make && make test && test/integration/run-tests -- cgit v1.2.3 From a1c4ae54803f85f83815cbf0f630ee867a2182e5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 17:31:24 +0200 Subject: add missing test make --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index ad51da3ef..47fc23656 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,9 @@ all headers library clean veryclean binary program doc manpages debiandoc test u $(MAKE) -C cmdline $@ $(MAKE) -C ftparchive $@ $(MAKE) -C dselect $@ + $(MAKE) -C doc $@ + $(MAKE) -C po $@ + $(MAKE) -C test $@ all headers library clean veryclean binary program doc manpages debiandoc test update-po: startup dirs -- cgit v1.2.3 From 36a0c0f78675d10cae840a72268f70aed667fb96 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 22:10:05 +0200 Subject: fix some coverity chroot() releated warnings --- apt-pkg/aptconfiguration.cc | 4 ++-- apt-pkg/deb/dpkgpm.cc | 1 + cmdline/apt-mark.cc | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) 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 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/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index fb0473535..588ab68c4 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/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); -- cgit v1.2.3 From 11d0fb919954e79f929ef5e755f602a6ed3be46d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 22:12:36 +0200 Subject: fix missing va_end() --- methods/ftp.cc | 1 + methods/rsh.cc | 2 ++ 2 files changed, 3 insertions(+) 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/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 -- cgit v1.2.3 From 163dc55bd6891008adcdf6d683a94e890a00f8c7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jul 2013 22:18:36 +0200 Subject: fix another missing va_end() --- apt-pkg/contrib/strutl.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; -- cgit v1.2.3