diff options
author | Steve Langasek <steve.langasek@linaro.org> | 2011-03-07 22:57:52 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-03-07 22:57:52 +0100 |
commit | 8e11253db6070bede2ecba01dbd3fde6019c8260 (patch) | |
tree | ce27a6491daff3920821df77d66850116021539d /apt-pkg | |
parent | 9e141dbd05e0304eada7e1eaf9a224018fa18132 (diff) | |
download | apt-8e11253db6070bede2ecba01dbd3fde6019c8260.tar.gz |
* apt-pkg/deb/dpkgpm.cc:
- make sure that for multiarch packages, we are passing the full
qualified package name to dpkg for removals. (Closes: #614298)
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 7d0d34a46..84443447f 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -881,7 +881,10 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Generate the argument list const char *Args[MaxArgs + 50]; - + // keep track of allocated strings for multiarch package names + char *Packages[MaxArgs + 50]; + unsigned int pkgcount = 0; + // Now check if we are within the MaxArgs limit // // this code below is problematic, because it may happen that @@ -989,13 +992,22 @@ bool pkgDPkgPM::Go(int OutStatusFd) } else { + string const nativeArch = _config->Find("APT::Architecture"); for (;I != J && Size < MaxArgBytes; I++) { if((*I).Pkg.end() == true) continue; if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end()) continue; - Args[n++] = I->Pkg.Name(); + if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all")) + Args[n++] = I->Pkg.Name(); + else + { + string const PkgDesc = I->Pkg.Name() + string(":") + string(I->Pkg.Arch()); + Packages[pkgcount] = new char[PkgDesc.size()+1]; + strncpy(Packages[pkgcount++],PkgDesc.c_str(),PkgDesc.size()+1); + Args[n++] = Packages[pkgcount-1]; + } Size += strlen(Args[n-1]); } } @@ -1145,6 +1157,11 @@ bool pkgDPkgPM::Go(int OutStatusFd) sigemptyset(&sigmask); sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); + /* clean up the temporary allocation for multiarch package names in + the parent, so we don't leak memory when we return. */ + for (unsigned int i = 0; i < pkgcount; i++) + delete [] Packages[i]; + // the result of the waitpid call int res; int select_ret; |