Skip to content

Commit

Permalink
tools/cxbe: Make while into for
Browse files Browse the repository at this point in the history
and changed the long section interpreter to assume not a long section if there is something other than numbers after the /
  • Loading branch information
PQCraft committed Jul 28, 2023
1 parent fbd7746 commit 2dd28ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/cxbe/Exe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ Exe::Exe(const char *x_szFilename)
for(uint32 i = 1; i < 8; ++i)
{
char c = m_SectionHeader[v].m_name[i];
if(c < '0' || c > '9')
if(!c)
break;
if(c < '0' || c > '9') // not a long section after all?
goto notlong;
m_SectionHeader_longname[v].m_offset *= 10;
m_SectionHeader_longname[v].m_offset += c - '0';
}
Expand All @@ -134,14 +136,13 @@ Exe::Exe(const char *x_szFilename)
fseek(ExeFile, m_Header.m_symbol_table_addr + m_SectionHeader_longname[v].m_offset,
SEEK_SET);

uint32 i = 0;
while(i < 255)
uint32 i;
for(i = 0; i < 255; ++i)
{
int c = fgetc(ExeFile);
if(!c || c == EOF)
break;
m_SectionHeader_longname[v].m_longname[i] = c;
++i;
}
m_SectionHeader_longname[v].m_longname[i] = 0;

Expand All @@ -151,6 +152,7 @@ Exe::Exe(const char *x_szFilename)
}
else
{
notlong:;
m_SectionHeader_longname[v].m_longname = NULL;
}

Expand Down

0 comments on commit 2dd28ba

Please sign in to comment.