aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2017-05-28 10:00:03 +0100
committerSimon Tatham <anakin@pobox.com>2017-05-28 10:00:03 +0100
commit0bc12e1c6704b1d34bebcf54770ee1a6434c3880 (patch)
tree6e2d320124f887aabacb337841ae858e753f9825
parentfe5eb01f9b84b344bd1d476f409626fd7b4cd5f9 (diff)
downloadwix-on-linux-0bc12e1c6704b1d34bebcf54770ee1a6434c3880.tar.gz
wix-on-linux-0bc12e1c6704b1d34bebcf54770ee1a6434c3880.tar.bz2
wix-on-linux-0bc12e1c6704b1d34bebcf54770ee1a6434c3880.zip
Fix WORD16 and WORD32 macros.
I made the mistake of using the same variable name _offset for the temporary variable in WORD16 and WORD32, and for the one in BYTE which the other two use as a subroutine - meaning that the declaration on the first line of BYTE read 'size_t _offset = _offset+3' or similar, in which the RHS _offset referred to the newly declared LHS one rather than to the one in the outer scope. WORD32 had the additional goof that I had declared its return-value accumulator variable as a 16- rather than 32-bit integer due to copy-and-paste error. Between those two mistakes - surely introduced at the last minute when I was doing code cleanup on this source base, because I know this function was working OK before then - I had completely broken the extraction of version strings from PE executables.
-rw-r--r--version.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/version.c b/version.c
index 7a48a5f..9e49559 100644
--- a/version.c
+++ b/version.c
@@ -40,22 +40,22 @@ uint32_t MsiGetFileVersionW(const char16_t *filename,
40 unsigned char *map = (unsigned char *)mapv; 40 unsigned char *map = (unsigned char *)mapv;
41 41
42#define BYTE(offset) ({ \ 42#define BYTE(offset) ({ \
43 size_t _offset = (offset); \ 43 size_t _boffset = (offset); \
44 if (_offset >= fsize) goto cleanup; /* outside file bounds */ \ 44 if (_boffset >= fsize) goto cleanup; /* outside file bounds */ \
45 map[_offset]; \ 45 map[_boffset]; \
46 }) 46 })
47#define WORD16(offset) ({ \ 47#define WORD16(offset) ({ \
48 size_t _offset = (offset); \ 48 size_t _woffset = (offset); \
49 uint16_t toret = BYTE(_offset+1); \ 49 uint16_t toret = BYTE(_woffset+1); \
50 toret = (toret << 8) | BYTE(_offset+0); \ 50 toret = (toret << 8) | BYTE(_woffset+0); \
51 toret; \ 51 toret; \
52 }) 52 })
53#define WORD32(offset) ({ \ 53#define WORD32(offset) ({ \
54 size_t _offset = (offset); \ 54 size_t _doffset = (offset); \
55 uint16_t toret = BYTE(_offset+3); \ 55 uint32_t toret = BYTE(_doffset+3); \
56 toret = (toret << 8) | BYTE(_offset+2); \ 56 toret = (toret << 8) | BYTE(_doffset+2); \
57 toret = (toret << 8) | BYTE(_offset+1); \ 57 toret = (toret << 8) | BYTE(_doffset+1); \
58 toret = (toret << 8) | BYTE(_offset+0); \ 58 toret = (toret << 8) | BYTE(_doffset+0); \
59 toret; \ 59 toret; \
60 }) 60 })
61 61