diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-03-20 17:05:11 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-03-20 17:05:11 +0100 |
commit | 31bda5000136d77f516cf2080257835fb44deaef (patch) | |
tree | b4c430aee7efcc71382ab73954612f6ff7fe3ef4 | |
parent | 05343a22b8c7d9b491e93169e035a996ff68af9f (diff) |
* apt-pkg/acquire-worker.cc:
- check return of write() as gcc recommends
* apt-pkg/acquire.cc:
- check return of write() as gcc recommends
* apt-pkg/cdrom.cc:
- check return of chdir() and link() as gcc recommends
* apt-pkg/clean.cc:
- check return of chdir() as gcc recommends
* apt-pkg/contrib/netrc.cc:
- check return of asprintf() as gcc recommends
-rw-r--r-- | apt-pkg/acquire-worker.cc | 18 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 18 | ||||
-rw-r--r-- | apt-pkg/cdrom.cc | 6 | ||||
-rw-r--r-- | apt-pkg/clean.cc | 11 | ||||
-rw-r--r-- | apt-pkg/contrib/netrc.cc | 3 | ||||
-rw-r--r-- | debian/changelog | 14 |
6 files changed, 58 insertions, 12 deletions
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 3bb977e14..d79b2b16d 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -431,7 +431,23 @@ bool pkgAcquire::Worker::MediaChange(string Message) << Drive << ":" // drive << msg.str() // l10n message << endl; - write(status_fd, status.str().c_str(), status.str().size()); + + std::string const dlstatus = status.str(); + size_t done = 0; + size_t todo = dlstatus.size(); + errno = 0; + int res = 0; + do + { + res = write(status_fd, dlstatus.c_str() + done, todo); + if (res < 0 && errno == EINTR) + continue; + if (res < 0) + break; + done += res; + todo -= res; + } + while (res > 0 && todo > 0); } if (Log == 0 || Log->MediaChange(LookupTag(Message,"Media"), diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 573a85c2f..19bcca8a1 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -872,7 +872,23 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) << ":" << (CurrentBytes/float(TotalBytes)*100.0) << ":" << msg << endl; - write(fd, status.str().c_str(), status.str().size()); + + std::string const dlstatus = status.str(); + size_t done = 0; + size_t todo = dlstatus.size(); + errno = 0; + int res = 0; + do + { + res = write(fd, dlstatus.c_str() + done, todo); + if (res < 0 && errno == EINTR) + continue; + if (res < 0) + break; + done += res; + todo -= res; + } + while (res > 0 && todo > 0); } return true; diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 4462d4e24..50c204371 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -430,7 +430,8 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) Out.close(); - link(DFile.c_str(),string(DFile + '~').c_str()); + if (FileExists(DFile) == true && link(DFile.c_str(),string(DFile + '~').c_str()) != 0) + return _error->Errno("link", "Failed to link %s to %s~", DFile.c_str(), DFile.c_str()); if (rename(NewFile.c_str(),DFile.c_str()) != 0) return _error->Errno("rename","Failed to rename %s.new to %s", DFile.c_str(),DFile.c_str()); @@ -697,7 +698,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ return false; } - chdir(StartDir.c_str()); + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir","Unable to change to %s", StartDir.c_str()); if (_config->FindB("Debug::aptcdrom",false) == true) { diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index ed8fa1aa9..9c167eaa5 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -54,9 +54,11 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) struct stat St; if (stat(Dir->d_name,&St) != 0) { - chdir(StartDir.c_str()); + _error->Errno("stat",_("Unable to stat %s."),Dir->d_name); closedir(D); - return _error->Errno("stat",_("Unable to stat %s."),Dir->d_name); + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir", _("Unable to change to %s"), StartDir.c_str()); + return false; } // Grab the package name @@ -115,8 +117,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) Erase(Dir->d_name,Pkg,Ver,St); }; - chdir(StartDir.c_str()); closedir(D); - return true; + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir", _("Unable to change to %s"), StartDir.c_str()); + return true; } /*}}}*/ diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index cb7d36088..56e59d84b 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -68,8 +68,7 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) if (!home) return -1; - asprintf (&netrcfile, "%s%s%s", home, DIR_CHAR, NETRC); - if(!netrcfile) + if (asprintf (&netrcfile, "%s%s%s", home, DIR_CHAR, NETRC) == -1 || netrcfile == NULL) return -1; else netrc_alloc = true; diff --git a/debian/changelog b/debian/changelog index 32b271668..22ed8a5a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,14 +3,24 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low [ Michael Vogt ] * apt-pkg/packagemanager.cc: - fix inconsistent clog/cout usage in the debug output - + [ David Kalnischkies ] * apt-pkg/packagemanager.cc: - recheck all dependencies if we changed a package in SmartConfigure as this could break an earlier dependency (LP: #940396) - recheck dependencies in SmartUnpack after a change, too + * apt-pkg/acquire-worker.cc: + - check return of write() as gcc recommends + * apt-pkg/acquire.cc: + - check return of write() as gcc recommends + * apt-pkg/cdrom.cc: + - check return of chdir() and link() as gcc recommends + * apt-pkg/clean.cc: + - check return of chdir() as gcc recommends + * apt-pkg/contrib/netrc.cc: + - check return of asprintf() as gcc recommends - -- David Kalnischkies <kalnischkies@gmail.com> Tue, 13 Mar 2012 12:38:35 +0100 + -- David Kalnischkies <kalnischkies@gmail.com> Tue, 20 Mar 2012 17:00:14 +0100 apt (0.8.16~exp13) experimental; urgency=low |