diff options
author | Neal H. Walfield <[email protected]> | 2016-02-02 19:05:45 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2016-02-14 13:46:24 +0000 |
commit | 5cdde08ea869ef02111f618ad782d392a296eb7f (patch) | |
tree | 566734015f49131f07763378dba07aa0c704bc66 /g10/build-packet.c | |
parent | gpg: Fix format_keyid when dynamically allocating the buffer. (diff) | |
download | gnupg-5cdde08ea869ef02111f618ad782d392a296eb7f.tar.gz gnupg-5cdde08ea869ef02111f618ad782d392a296eb7f.zip |
gpg: Fix calc_header_length when LEN is 0 and improve documentation.
* g10/build-packet.c (calc_header_length): Return the correct haeder
size when LEN is 0. Fix documentation.
--
Signed-off-by: Neal H. Walfield <[email protected]>
GnuPG-bug-id: 2240
Diffstat (limited to 'g10/build-packet.c')
-rw-r--r-- | g10/build-packet.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c index 269c63ca9..42452086d 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -1215,14 +1215,18 @@ write_32(IOBUF out, u32 a) /**************** - * calculate the length of a header + * calculate the length of a header. + * + * LEN is the length of the packet's body. NEW_CTB is whether we are + * using a new or old format packet. + * + * This function does not handle indeterminate lengths or partial body + * lengths. (If you pass LEN as 0, then this function assumes you + * really mean an empty body.) */ static int calc_header_length( u32 len, int new_ctb ) { - if( !len ) - return 1; /* only the ctb */ - if( new_ctb ) { if( len < 192 ) return 2; |