Skip to content
Snippets Groups Projects
Commit 8b56eeea authored by an7s's avatar an7s
Browse files

Remove static buffers

Former-commit-id: b38b2fe04cdb1e3922da22f0208cbfaaac7d5f40
parent a795b94f
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,6 @@
#include "MEDS_Register.hpp"
#include "MEDS_FuncPrototypeAnnotation.hpp"
#define MAX_BUF_SIZE 16000
using namespace std;
using namespace MEDS_Annotation;
......@@ -77,13 +75,15 @@ void MEDS_FuncPrototypeAnnotation::parse()
VirtualOffset vo(m_rawInputLine);
m_virtualOffset = vo;
const int maxbufsize = m_rawInputLine.size()*2;
if (about_inargs)
{
// 4046e0 71 FUNC INARGS 4 ARG0 1 ARG1 0 ARG2 0 ARG3 0
int numargs = 0;
char buf[MAX_BUF_SIZE];
strncpy(buf, m_rawInputLine.c_str(), MAX_BUF_SIZE-1);
buf[MAX_BUF_SIZE-1] = '\0';
char buf[maxbufsize]; bzero(buf, maxbufsize);
strncpy(buf, m_rawInputLine.c_str(), maxbufsize-1);
buf[maxbufsize-1] = '\0';
sscanf(buf, "%*x %*d %*s %*s %d %*s", &numargs);
for (int i = 0; i < numargs; ++i)
{
......@@ -92,7 +92,7 @@ void MEDS_FuncPrototypeAnnotation::parse()
char *zarg = strstr(buf, arg);
if (zarg)
{
char tmp[MAX_BUF_SIZE];
char tmp[maxbufsize];
int meds_type;
sscanf(tmp,"%*s %d %*s", &meds_type);
MEDS_Arg marg(meds_type);
......@@ -108,7 +108,7 @@ void MEDS_FuncPrototypeAnnotation::parse()
else if (about_return)
{
// 404740 697 FUNC RETURNTYPE RAX 1
char regbuf[MAX_BUF_SIZE];
char regbuf[maxbufsize]; bzero(regbuf, maxbufsize);
int meds_retType;
sscanf(m_rawInputLine.c_str(), "%*x %*d %*s %*s %s %d", regbuf, &meds_retType);
RegisterName reg = Register::getRegister(regbuf);
......
......@@ -171,6 +171,8 @@ void MEDS_InstructionCheckAnnotation::parse()
m_isInfiniteLoop = true;
}
const int maxbufsize = m_rawInputLine.size()*2;
// get bit width information for overflow & underflow
if (m_isOverflow || m_isUnderflow)
{
......@@ -180,8 +182,8 @@ void MEDS_InstructionCheckAnnotation::parse()
// 80483d5 3 INSTR CHECK UNDERFLOW SIGNED 16 CX ZZ sub cx, ax
// 804d51d 2 INSTR CHECK OVERFLOW UNSIGNED 32 EBX ZZ add ebx, eax
char buf[1024] = "";
char buf[maxbufsize]; bzero(buf, maxbufsize);
sscanf(m_rawInputLine.c_str(), "%*s %*d %*s %*s %*s %*s %d %s", &m_bitWidth, buf);
m_target = string(buf);
if (m_isNoFlag)
......@@ -191,8 +193,8 @@ void MEDS_InstructionCheckAnnotation::parse()
}
else if (m_isTruncation) // get bid width from/to information for truncation
{
char buf[1024] = "";
char buf2[1024] = "";
char buf[maxbufsize]; bzero(buf, maxbufsize);
char buf2[maxbufsize]; bzero(buf2, maxbufsize);
// [ADDR] [SIZE] INSTR CHECK TRUNCATION UNKNOWNSIGN 32 EAX 16 AX ZZ mov [esp+2Ah], ax
sscanf(m_rawInputLine.c_str(), "%*s %*d %*s %*s %*s %*s %d %s %d %s", &m_truncationFromWidth, buf, &m_truncationToWidth, buf2);
......@@ -210,7 +212,7 @@ void MEDS_InstructionCheckAnnotation::parse()
}
else if (m_isSignedness)
{
char buf[1024] = "";
char buf[maxbufsize]; bzero(buf, maxbufsize);
// [ADDR] [SIZE] INSTR CHECK SIGNEDNESS SIGNED 16 AX ZZ mov [esp+28h], ax
// [ADDR] [SIZE] INSTR CHECK SIGNEDNESS UNSIGNED 16 AX ZZ mov [esp+28h], ax
sscanf(m_rawInputLine.c_str(), "%*s %*d %*s %*s %*s %*s %d %s", &m_bitWidth, buf);
......@@ -224,7 +226,7 @@ void MEDS_InstructionCheckAnnotation::parse()
// 8048293 3 INSTR MEMSET STACKOFFSET_ESP 12 SIZE 24 ZZ call memset
if (m_rawInputLine.find("STACKOFFSET")!=string::npos)
{
char buf[1024] = "";
char buf[maxbufsize]; bzero(buf, maxbufsize);
sscanf(m_rawInputLine.c_str(), "%*s %*d %*s %*s %*s %d %*s %d", &m_stackOffset, &m_objectSize);
if (m_rawInputLine.find("STACKOFFSET_EBP")!=string::npos)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment