Fix buffer overflow in append_stacktrace
This has been causing Segmentation Faults while trying to write error
messages to the logs.
Also:  fix logic for detecting errors while calling addr2line or atos
(previously, addr2line_ok was always set to true, even after a failure)
@@ -158,7 +158,7 @@ static void write_eventlog(int level, const char *line, int len);
#define ERRORDATA_STACK_SIZE 10
#define CMD_BUFFER_SIZE 1024
-#define SYMBOL_SIZE 512
+#define SYMBOL_SIZE 2048
#define ADDRESS_SIZE 20
#define STACK_DEPTH_MAX 100
@@ -3631,9 +3631,9 @@ append_stacktrace(PipeProtoChunk *buffer, StringInfo append, void *const *stacka
}
}
- if (fd_ok && strlen(cmdresult[0]) > 1)
+ if (!fd_ok || strlen(cmdresult[0]) <= 1)
{
- addr2line_ok = true;
+ addr2line_ok = false;
}
if (fd != NULL)
@@ -3702,8 +3702,10 @@ append_stacktrace(PipeProtoChunk *buffer, StringInfo append, void *const *stacka
{
lineInfo = parenth + 1;
parenth = strrchr(lineInfo, ')');
+ if (parenth != NULL) {
*parenth = '\0';
}
+ }
/* line info added, print file and line info */
symbol_len = snprintf(symbol,
