summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-19 19:53:00 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-20 18:04:56 +0100
commit3a80d2a1866b57b8c07f62ce095d951458e18430 (patch)
treec049b88d5715b1f451ee613326937f3c9b2d2370 /openpgp/src/parse
parentffe6305f8be2bfb4106db177985c709493c7383d (diff)
openpgp: Keep track whether a container has been streamed.
- If a container was streamed, we can no longer compare it to other packets. Keep track of that, and use it in Container::PartialEq. - See #93.
Diffstat (limited to 'openpgp/src/parse')
-rw-r--r--openpgp/src/parse/parse.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs
index 3c46726b..3722f79b 100644
--- a/openpgp/src/parse/parse.rs
+++ b/openpgp/src/parse/parse.rs
@@ -3442,7 +3442,7 @@ impl <'a> PacketParser<'a> {
} else {
self.state = state_;
self.finish()?;
- // XXX self.content_was_read = false;
+ // XXX self.set_content_was_read(false);
let (fake_eof_, reader_) = buffered_reader_stack_pop(
reader_, recursion_depth - 1)?;
fake_eof = fake_eof_;
@@ -3600,7 +3600,12 @@ impl <'a> PacketParser<'a> {
/// # return Ok(());
/// # }
pub fn buffer_unread_content(&mut self) -> Result<&[u8]> {
+ // If the packet has not yet been streamed, then the following
+ // read operation should not be considered streaming.
+ let content_was_read = self.content_was_read;
let mut rest = self.steal_eof()?;
+ self.set_content_was_read(content_was_read);
+
match &mut self.packet {
Packet::Literal(p) => {
if rest.len() > 0 {
@@ -3721,10 +3726,17 @@ impl <'a> PacketParser<'a> {
/// Sets the content_was_read flag if `cond` is true.
fn mark_content_was_read(&mut self, cond: bool) {
if cond {
+ self.packet.container_mut().map(|c| c.set_streamed(true));
self.content_was_read = true;
}
}
+ /// Sets the content_was_read flag to `value`.
+ fn set_content_was_read(&mut self, value: bool) {
+ self.packet.container_mut().map(|c| c.set_streamed(value));
+ self.content_was_read = value;
+ }
+
/// Returns a reference to the current packet's header.
pub fn header(&self) -> &Header {
&self.header