Use inline functions to convert buffer data to scalars.
authorWerner Koch <wk@gnupg.org>
Sun, 22 Feb 2015 04:10:32 +0000 (23:10 -0500)
committerWerner Koch <wk@gnupg.org>
Mon, 23 Feb 2015 09:47:26 +0000 (10:47 +0100)
commit57af33d9e7c9b20b413b96882e670e75a67a5e65
tree695ad4ca32cb03e205c81d2d566a835c35e92732
parent7106165fd3161b614445d459df3b333d557d9d02
Use inline functions to convert buffer data to scalars.

* include/host2net.h (buf16_to_ulong, buf16_to_uint): New.
(buf16_to_ushort, buf16_to_u16): New.
(buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New.
--

This fixes sign extension on shift problems.  Hanno Böck found a case
with an invalid read due to this problem.  To fix that almost all uses
of "<< 24" and "<< 8" are changed by this patch to use an inline
function from host2net.h.

(back ported from commit 2183683bd633818dd031b090b5530951de76f392)

Signed-off-by: Werner Koch <wk@gnupg.org>
[dkg: rebased to STABLE-BRANCH-1-4]
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
12 files changed:
g10/apdu.c
g10/app-openpgp.c
g10/build-packet.c
g10/ccid-driver.c
g10/getkey.c
g10/keygen.c
g10/keyid.c
g10/misc.c
g10/parse-packet.c
g10/tdbio.c
g10/trustdb.c
include/host2net.h