diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-20 11:42:33 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-20 18:43:40 +0200 |
commit | c66712681b1367eea110edf8dc25dcf5c937828b (patch) | |
tree | 00fcba482ca5735374af285911de8fb6b6bd5848 /openpgp/src/serialize/stream.rs | |
parent | 4bd849d3face1918ec9888e1150a96200c75e80a (diff) |
openpgp: Don't finalize the PartialBodyFilter in Drop.
- Previously, PartialBodyFilter::drop made an effort to finalize the
filter. This, however, is only a best-effort mechanism: It cannot
report errors.
- Because of this, we now believe that it actually exacerbates the
problem of downstream users not finalizing the filter: It will
work most of the time, but sometimes fail.
- Drop the implementation of Drop. Fix all the problematic test
cases.
Diffstat (limited to 'openpgp/src/serialize/stream.rs')
-rw-r--r-- | openpgp/src/serialize/stream.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index 856914b3..0a6c0851 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -355,6 +355,7 @@ impl<'a> ArbitraryWriter<'a> { /// message.write_all(b"\x00")?; // filename length /// message.write_all(b"\x00\x00\x00\x00")?; // date /// message.write_all(b"Hello world.")?; // body + /// message.finalize()?; /// } /// assert_eq!(b"\xcb\x12t\x00\x00\x00\x00\x00Hello world.", /// sink.as_slice()); @@ -2402,6 +2403,7 @@ mod test { ustr.write_all(b"\x00").unwrap(); // fn length ustr.write_all(b"\x00\x00\x00\x00").unwrap(); // date ustr.write_all(b"Hello world.").unwrap(); // body + ustr.finalize().unwrap(); } let mut pp = PacketParser::from_bytes(&o).unwrap().unwrap(); @@ -2458,6 +2460,7 @@ mod test { let c = c.finalize_one().unwrap().unwrap(); // Pop the Compressor. let mut ls = LiteralWriter::new(c).format(T).build().unwrap(); write!(ls, "three").unwrap(); + ls.finalize().unwrap(); } let pile = PacketPile::from(reference); @@ -2524,6 +2527,7 @@ mod test { let c = ls.finalize_one().unwrap().unwrap(); let mut ls = LiteralWriter::new(c).format(T).build().unwrap(); write!(ls, "four").unwrap(); + ls.finalize().unwrap(); } let pile = PacketPile::from(reference); @@ -2623,6 +2627,7 @@ mod test { let mut literal = LiteralWriter::new(encryptor).build() .unwrap(); literal.write_all(message).unwrap(); + literal.finalize().unwrap(); } // ... and recover it... @@ -2809,7 +2814,7 @@ mod test { let mut literal = LiteralWriter::new(encryptor).build() .unwrap(); literal.write_all(&content).unwrap(); - // literal.finalize().unwrap(); + literal.finalize().unwrap(); } for &read_len in &[ |