提交 6602a789 编写于 作者: A Axel Sommerfeldt

checkEyecatchers() used to crash if a heap problem was detected

checkEyecatchers() used vsnprintf() with a format specifier "%d" to print the wrong eyecatcher content, but an eyecatcher was defined as 'double'.
Since "%d" expects an 'int' on the stack (which is usually 32 bit in size) but gets a 'double' instead (which is usually 64 bit), the following 'file' argument will be retrieved as wrong pointer value from stack, resulting in a crash in Log() -> vsnprintf() -> strlen().

This was fixed by defining 'eyecatcher' as 'uint64_t' (instead of 'double') and printing an eyecatcher using 'PRIx64' (instead of "d").
Signed-off-by: NAxel Sommerfeldt <axel.sommerfeldt@fastmail.de>
上级 122d9afc
......@@ -39,6 +39,7 @@ char* Broker_recordFFDC(char* symptoms);
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include "Heap.h"
......@@ -57,8 +58,9 @@ static mutex_type heap_mutex = &heap_mutex_store;
static heap_info state = {0, 0}; /**< global heap state information */
typedef double eyecatcherType;
typedef uint64_t eyecatcherType;
static eyecatcherType eyecatcher = (eyecatcherType)0x8888888888888888;
#define PRIeyecatcher PRIx64 /**< print eyecatcher in HEX notation */
/*#define HEAP_STACK 1 */
......@@ -224,7 +226,7 @@ static void checkEyecatchers(char* file, int line, void* p, size_t size)
eyecatcherType *sp = (eyecatcherType*)p;
char *cp = (char*)p;
eyecatcherType us;
static const char *msg = "Invalid %s eyecatcher %d in heap item at file %s line %d";
static const char *msg = "Invalid %s eyecatcher %" PRIeyecatcher " in heap item at file %s line %d";
if ((us = *--sp) != eyecatcher)
Log(LOG_ERROR, 13, msg, "start", us, file, line);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册