annotate src/common.h @ 359:a3e674fade6c

From Jeffrey Morlan: pst_parse_block misreads Table Contexts (aka "type 2") with a multi-block Row Matrix ("ind2"). Rows are never split between blocks - every block except the last has padding at the end which should be ignored. I've only seen this affect the recipients table, but presumably it could affect attachments too. This was causing out-of-bounds memory ranges to be returned from pst_getBlockOffset and later access; patch fixes both the table reading issue and adds a missing bounds check to pst_getBlockOffset (so as not to risk a segfault if the PST is corrupted).
author Carl Byington <carl@five-ten-sg.com>
date Wed, 06 Jul 2016 10:20:12 -0700
parents 5a82d41c883d
children 506e266f930d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
1
182
b65e8d0a088a more cleanup on external names in the shared object file
Carl Byington <carl@five-ten-sg.com>
parents: 133
diff changeset
2 #ifndef __PST_COMMON_H
b65e8d0a088a more cleanup on external names in the shared object file
Carl Byington <carl@five-ten-sg.com>
parents: 133
diff changeset
3 #define __PST_COMMON_H
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
4
123
ab2a11e72250 more cleanup of #include files.
Carl Byington <carl@five-ten-sg.com>
parents: 122
diff changeset
5
122
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
6 #include <stdlib.h>
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
7 #include <stdio.h>
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
8 #include <stdarg.h>
205
5f3fa53cb0e1 make nested mime multipart/alternative to hold the text/html parts
Carl Byington <carl@five-ten-sg.com>
parents: 182
diff changeset
9 #include <time.h>
122
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
10
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
11
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
12 #ifndef _MSC_VER
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
13 #include <stdint.h>
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
14 #include <inttypes.h>
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
15 #else
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
16 typedef signed char int8_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
17 typedef unsigned char uint8_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
18 typedef unsigned short uint16_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
19 typedef short int16_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
20 typedef unsigned int uint32_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
21 typedef int int32_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
22 typedef unsigned long long uint64_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
23 typedef long long int64_t;
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
24 #endif
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
25
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
26 #ifndef _WIN32
182
b65e8d0a088a more cleanup on external names in the shared object file
Carl Byington <carl@five-ten-sg.com>
parents: 133
diff changeset
27 typedef struct {
b65e8d0a088a more cleanup on external names in the shared object file
Carl Byington <carl@five-ten-sg.com>
parents: 133
diff changeset
28 uint32_t dwLowDateTime;
b65e8d0a088a more cleanup on external names in the shared object file
Carl Byington <carl@five-ten-sg.com>
parents: 133
diff changeset
29 uint32_t dwHighDateTime;
118
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 59
diff changeset
30 } FILETIME;
122
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
31 // According to Jan Wolter, sys/param.h is the most portable source of endian
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
32 // information on UNIX systems. see http://www.unixpapa.com/incnote/byteorder.html
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
33 #include <sys/param.h>
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
34 #else
133
2ec889a79e51 patch from Fridrich Strba, some systems need extra library for regex
Carl Byington <carl@five-ten-sg.com>
parents: 130
diff changeset
35 #include <windows.h>
229
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
36 #endif
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
37
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
38 #if defined(_WIN32) || defined(__DJGPP__)
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
39 #ifndef LITTLE_ENDIAN
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
40 #define LITTLE_ENDIAN 1234
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
41 #endif
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
42 #ifndef BIG_ENDIAN
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
43 #define BIG_ENDIAN 4321
e7f363452178 patch from Fridrich Strba for undefined ENDIAN
Carl Byington <carl@five-ten-sg.com>
parents: 205
diff changeset
44 #endif
122
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
45 #define BYTE_ORDER LITTLE_ENDIAN
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
46 #endif
118
0f1492b7fe8b patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents: 59
diff changeset
47
122
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
48
bdb38b434c0a more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
49 #endif
246
5a82d41c883d patches from Kenneth Berland for solaris
Carl Byington <carl@five-ten-sg.com>
parents: 229
diff changeset
50
5a82d41c883d patches from Kenneth Berland for solaris
Carl Byington <carl@five-ten-sg.com>
parents: 229
diff changeset
51 #if defined (__SVR4) && defined (__sun)
5a82d41c883d patches from Kenneth Berland for solaris
Carl Byington <carl@five-ten-sg.com>
parents: 229
diff changeset
52 #define LITTLE_ENDIAN 1234
5a82d41c883d patches from Kenneth Berland for solaris
Carl Byington <carl@five-ten-sg.com>
parents: 229
diff changeset
53 #define BYTE_ORDER LITTLE_ENDIAN
5a82d41c883d patches from Kenneth Berland for solaris
Carl Byington <carl@five-ten-sg.com>
parents: 229
diff changeset
54 #endif