diff options
author | Martin Willi <martin@revosec.ch> | 2013-05-03 14:17:37 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2013-05-03 14:17:37 +0200 |
commit | 9312fbc73d95587cc7abee146f8d92dc814497ab (patch) | |
tree | 1ac96ec2577330212e03e7207e3349d882648387 | |
parent | 1657b4ef269e35b6b7065ee6af9159f8fa05cfa1 (diff) | |
download | strongswan-9312fbc73d95587cc7abee146f8d92dc814497ab.tar.bz2 strongswan-9312fbc73d95587cc7abee146f8d92dc814497ab.tar.xz |
In memwipe_check(), don't put magic on stack when calling do_magic()
Otherwise the magic might be on the stack while checking it.
-rw-r--r-- | src/libstrongswan/library.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c index 170bc9f4b..d3ba49f46 100644 --- a/src/libstrongswan/library.c +++ b/src/libstrongswan/library.c @@ -164,7 +164,7 @@ static bool equals(char *a, char *b) * Write magic to memory, and try to clear it with memwipe() */ __attribute__((noinline)) -static void do_magic(int magic, int **stack) +static void do_magic(int *magic, int **stack) { int buf[MEMWIPE_WIPE_WORDS], i; @@ -172,7 +172,7 @@ static void do_magic(int magic, int **stack) *stack = &i; for (i = 0; i < countof(buf); i++) { - buf[i] = magic; + buf[i] = *magic; } /* passing buf to dbg should make sure the compiler can't optimize out buf. * we use directly dbg(3), as DBG3() might be stripped with DEBUG_LEVEL. */ @@ -187,7 +187,7 @@ static bool check_memwipe() { int magic = 0xCAFEBABE, *ptr, *deeper, i, stackdir = 1; - do_magic(magic, &deeper); + do_magic(&magic, &deeper); ptr = &magic; if (deeper < ptr) |