mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 02:18:37 +00:00
Fix 393099 - posix_memalign() invalid write if alignment == 0
Bug and analysis by Gabriel Ganne
This commit is contained in:
parent
718b47e184
commit
d9204e9eed
@ -1001,7 +1001,8 @@ static void init(void);
|
||||
\
|
||||
/* Test whether the alignment argument is valid. It must be \
|
||||
a power of two multiple of sizeof (void *). */ \
|
||||
if (alignment % sizeof (void *) != 0 \
|
||||
if (alignment == 0 \
|
||||
|| alignment % sizeof (void *) != 0 \
|
||||
|| (alignment & (alignment - 1)) != 0) \
|
||||
return VKI_EINVAL; \
|
||||
\
|
||||
|
||||
@ -82,7 +82,7 @@ int main ( void )
|
||||
# define PM(a,b,c) posix_memalign((void**)a, b, c)
|
||||
|
||||
res = PM(&p, -1,100); assert(EINVAL == res);
|
||||
res = PM(&p, 0, 100); assert(0 == res && 0 == (long)p % 8);
|
||||
res = PM(&p, 0, 100); assert(EINVAL == res);
|
||||
res = PM(&p, 1, 100); assert(EINVAL == res);
|
||||
res = PM(&p, 2, 100); assert(EINVAL == res);
|
||||
res = PM(&p, 3, 100); assert(EINVAL == res);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user