diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-05-25 14:46:45 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-08-26 13:52:57 +0200 |
| commit | 171c469927b1b7c5a4f81f113081985e7dc84597 (patch) | |
| tree | 17a7faafbe11f19a89fd846ecdbde943241bd625 | |
| parent | 82cc584ee916df6bc558559b62863b34b069a710 (diff) | |
edsp: Do not skip lines (fixes Architecture reading)
We skipped the Architecture: line because when the outer
loop got to it, the inner loop started and read the next
line after it.
Get rid of the nested loop instead, and first run a loop
to find the request line, and then a second loop to parse
the request flags.
An alternative would be to use a combined loop that
supports non-compliant protocol implementations, but
that's harder to read and we don't expect there to be
any especially on the request side.
| -rw-r--r-- | apt-pkg/edsp.cc | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 73c6889e5..6c9c3f3ee 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -595,46 +595,46 @@ bool EDSP::ReadRequest(int const input, std::list<std::string> &install, continue; // The first Tag must be a request, so search for it if (LineStartsWithAndStrip(line, "Request:")) - continue; + break; + } - while (ReadLine(input, line) == true) + while (ReadLine(input, line)) + { + // empty lines are the end of the request + if (line.empty() == true) { - // empty lines are the end of the request - if (line.empty() == true) - { - // Clear the architecture cache, since we may have set different ones - APT::Configuration::getArchitectures(false); - return true; - } + // Clear the architecture cache, since we may have set different ones + APT::Configuration::getArchitectures(false); + return true; + } - std::list<std::string> *request = NULL; - if (LineStartsWithAndStrip(line, "Install:")) - request = &install; - else if (LineStartsWithAndStrip(line, "Remove:")) - request = &remove; - else if (ReadFlag(flags, line, "Upgrade:", (Request::UPGRADE_ALL | Request::FORBID_REMOVE | Request::FORBID_NEW_INSTALL)) || + std::list<std::string> *request = NULL; + if (LineStartsWithAndStrip(line, "Install:")) + request = &install; + else if (LineStartsWithAndStrip(line, "Remove:")) + request = &remove; + else if (ReadFlag(flags, line, "Upgrade:", (Request::UPGRADE_ALL | Request::FORBID_REMOVE | Request::FORBID_NEW_INSTALL)) || ReadFlag(flags, line, "Dist-Upgrade:", Request::UPGRADE_ALL) || ReadFlag(flags, line, "Upgrade-All:", Request::UPGRADE_ALL) || ReadFlag(flags, line, "Forbid-New-Install:", Request::FORBID_NEW_INSTALL) || ReadFlag(flags, line, "Forbid-Remove:", Request::FORBID_REMOVE) || ReadFlag(flags, line, "Autoremove:", Request::AUTOREMOVE)) - ; - else if (LineStartsWithAndStrip(line, "Architecture:")) - _config->Set("APT::Architecture", line); - else if (LineStartsWithAndStrip(line, "Architectures:")) - _config->Set("APT::Architectures", SubstVar(line, " ", ",")); - else if (LineStartsWithAndStrip(line, "Machine-ID")) - _config->Set("APT::Machine-ID", line); - else if (LineStartsWithAndStrip(line, "Solver:")) - ; // purely informational line - else - _error->Warning("Unknown line in EDSP Request stanza: %s", line.c_str()); + ; + else if (LineStartsWithAndStrip(line, "Architecture:")) + _config->Set("APT::Architecture", line); + else if (LineStartsWithAndStrip(line, "Architectures:")) + _config->Set("APT::Architectures", SubstVar(line, " ", ",")); + else if (LineStartsWithAndStrip(line, "Machine-ID")) + _config->Set("APT::Machine-ID", line); + else if (LineStartsWithAndStrip(line, "Solver:")) + ; // purely informational line + else + _error->Warning("Unknown line in EDSP Request stanza: %s", line.c_str()); - if (request == NULL) - continue; - auto const pkgs = VectorizeString(line, ' '); - std::move(pkgs.begin(), pkgs.end(), std::back_inserter(*request)); - } + if (request == NULL) + continue; + auto const pkgs = VectorizeString(line, ' '); + std::move(pkgs.begin(), pkgs.end(), std::back_inserter(*request)); } return false; } /*}}}*/ |
