Use inline functions to convert buffer data to scalars.
authorWerner Koch <wk@gnupg.org>
Thu, 12 Feb 2015 19:34:44 +0000 (20:34 +0100)
committerWerner Koch <wk@gnupg.org>
Thu, 12 Feb 2015 19:34:44 +0000 (20:34 +0100)
commit3627123dc8fdc551caca1c7944713fbf01feccf6
tree2d5110fafab12628b09216c309f3fcc1ac9b68e4
parentb62395cf595bacc99124fae0c75afd3e76c856fc
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>
20 files changed:
common/iobuf.c
g10/build-packet.c
g10/getkey.c
g10/keygen.c
g10/keyid.c
g10/main.h
g10/misc.c
g10/parse-packet.c
g10/tdbio.c
g10/trustdb.c
include/host2net.h
kbx/keybox-dump.c
kbx/keybox-openpgp.c
kbx/keybox-search.c
kbx/keybox-update.c
scd/apdu.c
scd/app-openpgp.c
scd/ccid-driver.c
scd/pcsc-wrapper.c
tools/ccidmon.c