diff options
author | Sverker Eriksson <[email protected]> | 2010-02-18 14:59:46 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-02-18 14:59:46 +0000 |
commit | 3a44b99cc6f14a87242e2dddc57f191f853cfd90 (patch) | |
tree | acb6f863b54412f0b42f998711ba34e45216e665 /erts/emulator/beam | |
parent | e68da67280480bcd51e1a38372e5671a38082f82 (diff) | |
download | otp-3a44b99cc6f14a87242e2dddc57f191f853cfd90.tar.gz otp-3a44b99cc6f14a87242e2dddc57f191f853cfd90.tar.bz2 otp-3a44b99cc6f14a87242e2dddc57f191f853cfd90.zip |
OTP-8451 Harmless buffer overflow by one byte in asn1 and ram_file_drv.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/erl_binary.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_binary.h b/erts/emulator/beam/erl_binary.h index 21d4e3fdfd..1f948a9684 100644 --- a/erts/emulator/beam/erl_binary.h +++ b/erts/emulator/beam/erl_binary.h @@ -195,10 +195,20 @@ erts_free_aligned_binary_bytes(byte* buf) } } +/* Explicit extra bytes allocated to counter buggy drivers. +** These extra bytes where earlier (< R13B04) added by an alignment-bug +** in this code. Do we dare remove this in some major release (R14?) maybe? +*/ +#ifdef DEBUG +# define CHICKEN_PAD 0 +#else +# define CHICKEN_PAD (sizeof(void*) - 1) +#endif + ERTS_GLB_INLINE Binary * erts_bin_drv_alloc_fnf(Uint size) { - Uint bsize = ERTS_SIZEOF_Binary(size); + Uint bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD; void *res; res = erts_alloc_fnf(ERTS_ALC_T_DRV_BINARY, bsize); ERTS_CHK_BIN_ALIGNMENT(res); @@ -208,7 +218,7 @@ erts_bin_drv_alloc_fnf(Uint size) ERTS_GLB_INLINE Binary * erts_bin_drv_alloc(Uint size) { - Uint bsize = ERTS_SIZEOF_Binary(size); + Uint bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD; void *res; res = erts_alloc(ERTS_ALC_T_DRV_BINARY, bsize); ERTS_CHK_BIN_ALIGNMENT(res); @@ -219,7 +229,7 @@ erts_bin_drv_alloc(Uint size) ERTS_GLB_INLINE Binary * erts_bin_nrml_alloc(Uint size) { - Uint bsize = ERTS_SIZEOF_Binary(size); + Uint bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD; void *res; res = erts_alloc(ERTS_ALC_T_BINARY, bsize); ERTS_CHK_BIN_ALIGNMENT(res); @@ -230,7 +240,7 @@ ERTS_GLB_INLINE Binary * erts_bin_realloc_fnf(Binary *bp, Uint size) { Binary *nbp; - Uint bsize = ERTS_SIZEOF_Binary(size); + Uint bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD; ASSERT((bp->flags & BIN_FLAG_MAGIC) == 0); if (bp->flags & BIN_FLAG_DRV) nbp = erts_realloc_fnf(ERTS_ALC_T_DRV_BINARY, (void *) bp, bsize); @@ -244,7 +254,7 @@ ERTS_GLB_INLINE Binary * erts_bin_realloc(Binary *bp, Uint size) { Binary *nbp; - Uint bsize = ERTS_SIZEOF_Binary(size); + Uint bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD; ASSERT((bp->flags & BIN_FLAG_MAGIC) == 0); if (bp->flags & BIN_FLAG_DRV) nbp = erts_realloc_fnf(ERTS_ALC_T_DRV_BINARY, (void *) bp, bsize); |