Skip to content

Commit

Permalink
Fixed potential unaligned load, as reported by UBSAN.
Browse files Browse the repository at this point in the history
  • Loading branch information
vlutas committed May 28, 2024
1 parent 63ca9e4 commit 91f04ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable (user-facing) changes to this project will be documented in this fil
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [2.1.5] - 2024-05-28

### Fixed
- Potential unaligned load, as reported by UBSAN.


## [2.1.4] - 2024-03-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion bindings/pybddisasm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from codecs import open

VERSION = (0, 3, 0)
LIBRARY_VERSION = (2, 1, 4)
LIBRARY_VERSION = (2, 1, 5)
DIR_INCLUDE = '../../inc'

here = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion inc/bddisasm_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define DISASM_VERSION_MAJOR 2
#define DISASM_VERSION_MINOR 1
#define DISASM_VERSION_REVISION 4
#define DISASM_VERSION_REVISION 5

#define SHEMU_VERSION_MAJOR DISASM_VERSION_MAJOR
#define SHEMU_VERSION_MINOR DISASM_VERSION_MINOR
Expand Down
16 changes: 5 additions & 11 deletions inc/bdx86_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,11 @@ typedef ND_UINT32 ND_REG_SIZE;
// Sets the sign of the sz bytes long value x.
#define ND_SET_SIGN(sz, x) ND_SIGN_EX(sz, x)

#ifdef BIG_ENDIAN
#define ND_FETCH_64(b) ((ND_UINT64)ND_FETCH_32((char *)b) | ((ND_UINT64)ND_FETCH_32((char *)b + 4) << 32))
#define ND_FETCH_32(b) ((ND_UINT32)ND_FETCH_16((char *)b) | ((ND_UINT32)ND_FETCH_16((char *)b + 2) << 16))
#define ND_FETCH_16(b) ((((char *)b)[0]) | (((char *)b)[1] << 8))
#define ND_FETCH_8(b) (*((char *)b))
#else
#define ND_FETCH_64(b) (*((ND_UINT64 *)(b)))
#define ND_FETCH_32(b) (*((ND_UINT32 *)(b)))
#define ND_FETCH_16(b) (*((ND_UINT16 *)(b)))
#define ND_FETCH_8(b) (*((ND_UINT8 *)(b)))
#endif
#define ND_FETCH_64(b) (((ND_UINT64)ND_FETCH_32((ND_UINT8 *)b)) | (((ND_UINT64)ND_FETCH_32((ND_UINT8 *)b + 4) << 32)))
#define ND_FETCH_32(b) (((ND_UINT32)ND_FETCH_16((ND_UINT8 *)b)) | (((ND_UINT32)ND_FETCH_16((ND_UINT8 *)b + 2) << 16)))
#define ND_FETCH_16(b) (((ND_UINT16)ND_FETCH_8 ((ND_UINT8 *)b)) | (((ND_UINT16)ND_FETCH_8 ((ND_UINT8 *)b + 1) << 8)))
#define ND_FETCH_8(b) (*((ND_UINT8 *)b))



//
Expand Down

0 comments on commit 91f04ed

Please sign in to comment.