From bf46e09f0e4b52b3c71ac20bb11e7511fc16179f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 21 Mar 2020 08:14:15 +0100 Subject: Parse last line in deb file correctly by adding a newline While merging apt-pkg and apt-inst libraries the codepath of handling deb files in apt-pkg was adapted to use the 'old' code from apt-inst instead of fork&exec of dpkg-deb -I. The information we get this way forms the main part of the package stanza, but we add a few semi-optional fields to the stanza to make it look and work more like a stanza we got from a repository. Just be careful with the area where these two parts touch as if, hypothetically, we would stip all newlines around the parts, but forget to add a newline between them later, the two lines around the merge would stick a bit too close together forming one which could result in fun parsing errors if this merged line was previously e.g. a well-formed Depends line and has now extra fluff attached. This codepath has a history with too many newlines (#802553) though, so how likely is it really that it will some day lack one you may ask. References: 6089a4b17c61ef30b2efc00e270b0907f51f352a --- apt-pkg/deb/debindexfile.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb/debindexfile.cc') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 43317d314..e1698e151 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -189,7 +189,7 @@ bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &de while (isspace_ascii(Control[0])) Control++; - content << Control; + content << Control << '\n'; content << "Filename: " << debfile << "\n"; content << "Size: " << std::to_string(Buf.st_size) << "\n"; -- cgit v1.2.3