mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
common: Avoid undefined behavior of left shift operator.
* common/iobuf.c (block_filter): Handle an error earlier. Make sure it's unsigned. -- GnuPG-bug-id: 4975 Suggested-by: lutianxiong <lutianxiong@huawei.com> Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
91cb46d948
commit
8abf065307
@ -909,16 +909,22 @@ block_filter (void *opaque, int control, iobuf_t chain, byte * buffer,
|
||||
}
|
||||
else if (c == 255)
|
||||
{
|
||||
a->size = iobuf_get_noeof (chain) << 24;
|
||||
a->size |= iobuf_get_noeof (chain) << 16;
|
||||
a->size |= iobuf_get_noeof (chain) << 8;
|
||||
if ((c = iobuf_get (chain)) == -1)
|
||||
size_t len = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
if ((c = iobuf_get (chain)) == -1)
|
||||
break;
|
||||
else
|
||||
len = ((len << 8) | c);
|
||||
|
||||
if (i < 4)
|
||||
{
|
||||
log_error ("block_filter: invalid 4 byte length\n");
|
||||
rc = GPG_ERR_BAD_DATA;
|
||||
break;
|
||||
}
|
||||
a->size |= c;
|
||||
a->size = len;
|
||||
a->partial = 2;
|
||||
if (!a->size)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user