]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/acquire-worker.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Tue, 20 Mar 2012 16:05:11 +0000 (17:05 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Tue, 20 Mar 2012 16:05:11 +0000 (17:05 +0100)
  - 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

apt-pkg/acquire-worker.cc
apt-pkg/acquire.cc
apt-pkg/cdrom.cc
apt-pkg/clean.cc
apt-pkg/contrib/netrc.cc
debian/changelog

index 3bb977e1403f42a3920463f771f0a956024e9200..d79b2b16dfb22c3021ebda26ecbbcf4de204420c 100644 (file)
@@ -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"),
index 573a85c2fafc0aeea5b62ef619bee50ec4ce9c2d..19bcca8a1face10e942b00f0d30c0076cc8180e1 100644 (file)
@@ -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;
index 4462d4e246abb0273031d88c1568739b6117e2e8..50c2043716b274931c3a0614295f6aad8c81eca3 100644 (file)
@@ -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)
    {
index ed8fa1aa9c8dabac4ee5080b11cd2c901a275065..9c167eaa505b82b3ae593f5c226f9c20506d49a8 100644 (file)
@@ -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;
 }
                                                                        /*}}}*/
index cb7d36088c5d46b57502adcfb35c996d61577ea6..56e59d84b89b64635158e6a74db0156260c753a2 100644 (file)
@@ -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;
index 32b271668f457276c633fd0d050ee68949db292e..22ed8a5a561368c8a697b0d60ca4b610fa388352 100644 (file)
@@ -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