|
From: <sag...@us...> - 2010-09-01 14:24:10
|
Revision: 694
http://modplug.svn.sourceforge.net/modplug/?rev=694&view=rev
Author: saga-games
Date: 2010-09-01 14:24:04 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
[Fix] Text length was calculated wrong in the message reader, leading to a possible buffer overflow when reading song messages with mixed line endings where CR or LF line endings where expected.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Message.cpp
Modified: trunk/OpenMPT/soundlib/Message.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Message.cpp 2010-08-31 22:09:17 UTC (rev 693)
+++ trunk/OpenMPT/soundlib/Message.cpp 2010-09-01 14:24:04 UTC (rev 694)
@@ -95,18 +95,8 @@
if(pTextConverter != nullptr)
pTextConverter(c);
- switch(c)
- {
- case '\r':
- if(lineEnding != leLF) final_length++;
- break;
- case '\n':
- if(lineEnding != leCR && lineEnding != leCRLF) final_length++;
- break;
- default:
+ if(c != '\n' || lineEnding != leCRLF)
final_length++;
- break;
- }
}
if(!AllocateMessage(final_length))
@@ -198,13 +188,13 @@
LPCSTR p = m_lpszSongComments;
if (!p) return 0;
UINT i = 2, ln=0;
- if ((len) && (s)) s[0] = '\x0D';
- if ((len > 1) && (s)) s[1] = '\x0A';
+ if ((len) && (s)) s[0] = '\r';
+ if ((len > 1) && (s)) s[1] = '\n';
while ((*p) && (i+2 < len))
{
BYTE c = (BYTE)*p++;
if ((c == 0x0D) || ((c == ' ') && (ln >= linesize)))
- { if (s) { s[i++] = '\x0D'; s[i++] = '\x0A'; } else i+= 2; ln=0; }
+ { if (s) { s[i++] = '\r'; s[i++] = '\n'; } else i+= 2; ln=0; }
else
if (c >= 0x20) { if (s) s[i++] = c; else i++; ln++; }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|