mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-24 15:36:33 +00:00
Handle DOS newlines in ASCII rdc file sections
This commit is contained in:
@@ -456,6 +456,17 @@ void RDCFile::Init(StreamReader &reader)
|
||||
// ASCII section
|
||||
char c = 0;
|
||||
reader.Read(c);
|
||||
|
||||
if(c == '\r')
|
||||
reader.Read(c);
|
||||
|
||||
if(c != '\n')
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted,
|
||||
"Invalid newline sequence in ASCII data section");
|
||||
return;
|
||||
}
|
||||
|
||||
if(reader.IsErrored())
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted, "Invalid ASCII data section '%hhx'", c);
|
||||
@@ -472,17 +483,29 @@ void RDCFile::Init(StreamReader &reader)
|
||||
|
||||
c = '0';
|
||||
|
||||
while(!reader.IsErrored() && c != '\n')
|
||||
while(!reader.IsErrored() && c != '\r' && c != '\n')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c == '\n' || reader.IsErrored())
|
||||
if(c == '\r' || c == '\n' || reader.IsErrored())
|
||||
break;
|
||||
|
||||
length *= 10;
|
||||
length += int(c - '0');
|
||||
}
|
||||
|
||||
if(c == '\r')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c != '\n')
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted,
|
||||
"Invalid newline sequence in ASCII data section");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(reader.IsErrored() || reader.AtEnd())
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted, "Invalid truncated ASCII data section");
|
||||
@@ -493,17 +516,29 @@ void RDCFile::Init(StreamReader &reader)
|
||||
|
||||
c = '0';
|
||||
|
||||
while(!reader.AtEnd() && c != '\n')
|
||||
while(!reader.AtEnd() && c != '\r' && c != '\n')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c == '\n' || reader.IsErrored())
|
||||
if(c == '\r' || c == '\n' || reader.IsErrored())
|
||||
break;
|
||||
|
||||
type *= 10;
|
||||
type += int(c - '0');
|
||||
}
|
||||
|
||||
if(c == '\r')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c != '\n')
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted,
|
||||
"Invalid newline sequence in ASCII data section");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(reader.IsErrored() || reader.AtEnd())
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted, "Invalid truncated ASCII data section");
|
||||
@@ -514,17 +549,29 @@ void RDCFile::Init(StreamReader &reader)
|
||||
|
||||
c = '0';
|
||||
|
||||
while(!reader.AtEnd() && c != '\n')
|
||||
while(!reader.AtEnd() && c != '\r' && c != '\n')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c == '\n' || reader.IsErrored())
|
||||
if(c == '\r' || c == '\n' || reader.IsErrored())
|
||||
break;
|
||||
|
||||
version *= 10;
|
||||
version += int(c - '0');
|
||||
}
|
||||
|
||||
if(c == '\r')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c != '\n')
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted,
|
||||
"Invalid newline sequence in ASCII data section");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(reader.IsErrored() || reader.AtEnd())
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted, "Invalid truncated ASCII data section");
|
||||
@@ -535,14 +582,27 @@ void RDCFile::Init(StreamReader &reader)
|
||||
|
||||
c = 0;
|
||||
|
||||
while(!reader.AtEnd() && c != '\n')
|
||||
while(!reader.AtEnd() && c != '\r' && c != '\n')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c == 0 || c == '\n' || reader.IsErrored())
|
||||
if(c == '\r' || c == '\n' || reader.IsErrored())
|
||||
break;
|
||||
|
||||
name.push_back(c);
|
||||
if(c != 0)
|
||||
name.push_back(c);
|
||||
}
|
||||
|
||||
if(c == '\r')
|
||||
{
|
||||
reader.Read(c);
|
||||
|
||||
if(c != '\n')
|
||||
{
|
||||
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted,
|
||||
"Invalid newline sequence in ASCII data section");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(reader.IsErrored() || reader.AtEnd())
|
||||
|
||||
Reference in New Issue
Block a user