1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-23 15:07:03 +01:00

(write_plaintext_packet): Fixed the detection of too

large files in the same way as in encode.c.
This commit is contained in:
Werner Koch 2004-05-07 09:32:53 +00:00
parent 0c8c110b17
commit 88dcf26646
2 changed files with 18 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2004-05-07 Werner Koch <wk@gnupg.org>
* sign.c (write_plaintext_packet): Fixed the detection of too
large files in the same way as in encode.c.
2004-04-22 David Shaw <dshaw@jabberwocky.com> 2004-04-22 David Shaw <dshaw@jabberwocky.com>
* keygen.c (make_backsig): If DO_BACKSIGS is not defined, do not * keygen.c (make_backsig): If DO_BACKSIGS is not defined, do not

View File

@ -467,19 +467,24 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode)
/* try to calculate the length of the data */ /* try to calculate the length of the data */
if (fname && *fname && !(*fname=='-' && !fname[1])) { if (fname && *fname && !(*fname=='-' && !fname[1])) {
if( !(filesize = iobuf_get_filelength(inp)) ) off_t tmpsize;
if( !(tmpsize = iobuf_get_filelength(inp)) )
log_info (_("WARNING: `%s' is an empty file\n"), fname); log_info (_("WARNING: `%s' is an empty file\n"), fname);
/* we can't yet encode the length of very large files, /* We can't encode the length of very large files because
* so we switch to partial length encoding in this case */ OpenPGP uses only 32 bit for file sizes. So if the size of
if (filesize >= IOBUF_FILELENGTH_LIMIT) a file is larger than 2^32 minus some bytes for packet
filesize = 0; headers, we switch to partial length encoding. */
if ( tmpsize < (IOBUF_FILELENGTH_LIMIT - 65536) )
filesize = tmpsize;
else
filesize = 0;
/* because the text_filter modifies the length of the /* Because the text_filter modifies the length of the
* data, it is not possible to know the used length * data, it is not possible to know the used length
* without a double read of the file - to avoid that * without a double read of the file - to avoid that
* we simple use partial length packets. * we simple use partial length packets. */
*/
if ( ptmode == 't' ) if ( ptmode == 't' )
filesize = 0; filesize = 0;
} }