aboutsummaryrefslogtreecommitdiffstats
path: root/g10/parse-packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/parse-packet.c')
-rw-r--r--g10/parse-packet.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index e7e923b78..862ec6e7f 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -35,6 +35,7 @@
#include "options.h"
#include "main.h"
#include "i18n.h"
+#include "host2net.h"
#ifndef MAX_EXTERN_MPI_BITS
#define MAX_EXTERN_MPI_BITS 16384
@@ -94,7 +95,7 @@ static unsigned short
read_16(IOBUF inp)
{
unsigned short a;
- a = iobuf_get_noeof(inp) << 8;
+ a = (unsigned short)iobuf_get_noeof(inp) << 8;
a |= iobuf_get_noeof(inp);
return a;
}
@@ -103,7 +104,7 @@ static unsigned long
read_32(IOBUF inp)
{
unsigned long a;
- a = iobuf_get_noeof(inp) << 24;
+ a = (unsigned long)iobuf_get_noeof(inp) << 24;
a |= iobuf_get_noeof(inp) << 16;
a |= iobuf_get_noeof(inp) << 8;
a |= iobuf_get_noeof(inp);
@@ -383,7 +384,8 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
}
else if( c == 255 )
{
- pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
+ pktlen =
+ (unsigned long)(hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16;
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8;
if( (c = iobuf_get(inp)) == -1 )
@@ -878,14 +880,15 @@ dump_sig_subpkt( int hashed, int type, int critical,
switch( type ) {
case SIGSUBPKT_SIG_CREATED:
if( length >= 4 )
- fprintf (listfp, "sig created %s", strtimestamp( buffer_to_u32(buffer) ) );
+ fprintf (listfp, "sig created %s",
+ strtimestamp (buf32_to_u32(buffer)) );
break;
case SIGSUBPKT_SIG_EXPIRE:
if( length >= 4 )
{
- if(buffer_to_u32(buffer))
+ if(buf32_to_u32(buffer))
fprintf (listfp, "sig expires after %s",
- strtimevalue( buffer_to_u32(buffer) ) );
+ strtimevalue( buf32_to_u32(buffer) ) );
else
fprintf (listfp, "sig does not expire");
}
@@ -918,9 +921,9 @@ dump_sig_subpkt( int hashed, int type, int critical,
case SIGSUBPKT_KEY_EXPIRE:
if( length >= 4 )
{
- if(buffer_to_u32(buffer))
+ if(buf32_to_u32(buffer))
fprintf (listfp, "key expires after %s",
- strtimevalue( buffer_to_u32(buffer) ) );
+ strtimevalue( buf32_to_u32(buffer) ) );
else
fprintf (listfp, "key does not expire");
}
@@ -943,8 +946,8 @@ dump_sig_subpkt( int hashed, int type, int critical,
case SIGSUBPKT_ISSUER:
if( length >= 8 )
fprintf (listfp, "issuer key ID %08lX%08lX",
- (ulong)buffer_to_u32(buffer),
- (ulong)buffer_to_u32(buffer+4) );
+ buf32_to_ulong (buffer),
+ buf32_to_ulong (buffer+4));
break;
case SIGSUBPKT_NOTATION:
{
@@ -1192,8 +1195,7 @@ enum_sig_subpkt( const subpktarea_t *pktbuf, sigsubpkttype_t reqtype,
if( n == 255 ) { /* 4 byte length header */
if( buflen < 4 )
goto too_short;
- n = (buffer[0] << 24) | (buffer[1] << 16)
- | (buffer[2] << 8) | buffer[3];
+ n = buf32_to_size_t (buffer);
buffer += 4;
buflen -= 4;
}
@@ -1415,7 +1417,7 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen,
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_SIG_CREATED, NULL );
if(p)
- sig->timestamp = buffer_to_u32(p);
+ sig->timestamp = buf32_to_u32 (p);
else if(!(sig->pubkey_algo>=100 && sig->pubkey_algo<=110)
&& opt.verbose)
log_info ("signature packet without timestamp\n");
@@ -1423,16 +1425,16 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen,
p = parse_sig_subpkt2( sig, SIGSUBPKT_ISSUER, NULL );
if(p)
{
- sig->keyid[0] = buffer_to_u32(p);
- sig->keyid[1] = buffer_to_u32(p+4);
+ sig->keyid[0] = buf32_to_u32 (p);
+ sig->keyid[1] = buf32_to_u32 (p+4);
}
else if(!(sig->pubkey_algo>=100 && sig->pubkey_algo<=110)
&& opt.verbose)
log_info ("signature packet without keyid\n");
p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_SIG_EXPIRE,NULL);
- if(p && buffer_to_u32(p))
- sig->expiredate=sig->timestamp+buffer_to_u32(p);
+ if(p && buf32_to_u32 (p))
+ sig->expiredate = sig->timestamp + buf32_to_u32 (p);
if(sig->expiredate && sig->expiredate<=make_timestamp())
sig->flags.expired=1;
@@ -2032,9 +2034,8 @@ parse_attribute_subpkts(PKT_user_id *uid)
if( n == 255 ) { /* 4 byte length header */
if( buflen < 4 )
goto too_short;
- n = (buffer[0] << 24) | (buffer[1] << 16)
- | (buffer[2] << 8) | buffer[3];
- buffer += 4;
+ n = buf32_to_size_t (buffer);
+ buffer += 4;
buflen -= 4;
}
else if( n >= 192 ) { /* 2 byte special encoded length header */