summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2013-03-19 12:37:50 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2013-03-19 12:37:50 +0100
commitcb32348956441e33733e6bd8c2c572f19600dc25 (patch)
treed5ad7114da5ebb0c4620b3a2711e045a9268a9fb
parentb408e4ad0010b273dac0af7dc87ab61062d89e49 (diff)
support dash-escaped text in clearsigned files as implementations are
free to escape all lines (we have no lines in our files which need to be escaped as these would be invalid fieldnames) and while ExecGPGV would detect dash-escaped text as invalid (as its not expected in messages with detached signatures) it would be possible to "comment" lines in (signed) dsc files which are only parsed but not verified
-rw-r--r--apt-pkg/contrib/gpgv.cc23
-rw-r--r--apt-pkg/contrib/gpgv.h3
2 files changed, 12 insertions, 14 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 54cc4c6d0..ba059dd87 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -298,20 +298,21 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
SignatureFile->Write("\n", 1);
}
}
- else if (found_message_end == false)
+ else if (found_message_end == false) // we are in the message block
{
- // we are in the message block
+ // we don't have any fields which need dash-escaped,
+ // but implementations are free to encode all lines …
+ char const * dashfree = buf;
+ if (strncmp(dashfree, "- ", 2) == 0)
+ dashfree += 2;
if(first_line == true) // first line does not need a newline
- {
- if (ContentFile != NULL)
- ContentFile->Write(buf, strlen(buf));
first_line = false;
- }
else if (ContentFile != NULL)
- {
ContentFile->Write("\n", 1);
- ContentFile->Write(buf, strlen(buf));
- }
+ else
+ continue;
+ if (ContentFile != NULL)
+ ContentFile->Write(dashfree, strlen(dashfree));
}
}
else if (found_signature == true)
@@ -333,10 +334,10 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
// if we haven't found any of them, this an unsigned file,
// so don't generate an error, but splitting was unsuccessful none-the-less
- if (found_message_start == false && found_message_end == false)
+ if (first_line == true && found_message_start == false && found_message_end == false)
return false;
// otherwise one missing indicates a syntax error
- else if (found_message_start == false || found_message_end == false)
+ else if (first_line == false || found_message_start == false || found_message_end == false)
return _error->Error("Splitting of file %s failed as it doesn't contain all expected parts", InFile.c_str());
return true;
diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h
index 1f877fc2d..08b10a97a 100644
--- a/apt-pkg/contrib/gpgv.h
+++ b/apt-pkg/contrib/gpgv.h
@@ -51,9 +51,6 @@ inline void ExecGPGV(std::string const &File, std::string const &FileSig,
* If a FileFd pointers is NULL it will not be used and the content
* which would have been written to it is silently discarded.
*
- * The code doesn't support dash-encoded lines as these are not
- * expected to be present in files we have to deal with.
- *
* The content of the split files is undefined if the splitting was
* unsuccessful.
*