aboutsummaryrefslogtreecommitdiffstats
path: root/g10/build-packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/build-packet.c')
-rw-r--r--g10/build-packet.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 57d75758a..a7e03ae0b 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -460,7 +460,14 @@ do_pubkey_enc( IOBUF out, int ctb, PKT_pubkey_enc *enc )
static u32
calc_plaintext( PKT_plaintext *pt )
{
- return pt->len? (1 + 1 + pt->namelen + 4 + pt->len) : 0;
+ /* Truncate namelen to the maximum 255 characters. Note this means
+ that a function that calls build_packet with an illegal literal
+ packet will get it back legalized. */
+
+ if(pt->namelen>255)
+ pt->namelen=255;
+
+ return pt->len? (1 + 1 + pt->namelen + 4 + pt->len) : 0;
}
static int
@@ -471,12 +478,6 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
byte buf[1000]; /* this buffer has the plaintext! */
int nbytes;
- /* Truncate namelen to the maximum 255 characters. This does mean
- that a function that calls build_packet with an illegal literal
- packet will get it back legalized. */
- if(pt->namelen>255)
- pt->namelen=255;
-
write_header(out, ctb, calc_plaintext( pt ) );
iobuf_put(out, pt->mode );
iobuf_put(out, pt->namelen );