File postgresql-CVE-2010-4014.patch of Package postgresql
Index: src/backend/utils/error/elog.c
===================================================================
--- src/backend/utils/error/elog.c.orig
+++ src/backend/utils/error/elog.c
@@ -2123,8 +2123,9 @@ error_severity(int elevel)
/*
* append_with_tabs
*
- * Append the string to the StringInfo buffer, inserting a tab after any
- * newline.
+ * Append the string to the StringInfo buffer, converting
+ * carriage returns and CRNL sequences to newline and inserting a
+ * tab after any (resulting) newline character.
*/
static void
append_with_tabs(StringInfo buf, const char *str)
@@ -2133,7 +2134,14 @@ append_with_tabs(StringInfo buf, const c
while ((ch = *str++) != '\0')
{
+ /* ignore CR if followed by NL */
+ if (ch == '\r' && *str == '\n')
+ continue;
+ /* convert a single CR to NL */
+ if (ch == '\r')
+ ch = '\n';
appendStringInfoCharMacro(buf, ch);
+ /* indent multi-line log entries */
if (ch == '\n')
appendStringInfoCharMacro(buf, '\t');
}