1
0
Fork 0

DBG: fixed most strcpy_s problems

This commit is contained in:
Mr. eXoDia 2015-02-02 00:58:25 +01:00
parent 9178b28ece
commit d1c92eeb55
28 changed files with 117 additions and 115 deletions

View File

@ -259,7 +259,7 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //(
return false;
sprintf_s(info.label, "&%s", ptrinfo.label);
}
strcpy(text, info.label);
strcpy_s(text, MAX_LABEL_SIZE, info.label);
return true;
}
@ -270,7 +270,7 @@ BRIDGE_IMPEXP bool DbgSetLabelAt(duint addr, const char* text)
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags = flaglabel;
strcpy(info.label, text);
strcpy_s(info.label, text);
if(!_dbg_addrinfoset(addr, &info))
return false;
return true;
@ -285,7 +285,7 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live)
info.flags = flagcomment;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return false;
strcpy(text, info.comment);
strcpy_s(text, MAX_COMMENT_SIZE, info.comment);
return true;
}

View File

@ -60,6 +60,7 @@ BRIDGE_IMPEXP int BridgeGetDbgVersion();
#define MAX_STRING_SIZE 512
#define MAX_ERROR_SIZE 512
#define RIGHTS_STRING_SIZE (sizeof("ERWCG") + 1)
#define MAX_SECTION_SIZE 10
#define TYPE_VALUE 1
#define TYPE_MEMORY 2

View File

@ -42,7 +42,7 @@ static bool _sectionfromaddr(duint addr, char* section)
{
const char* name = (const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
if(section)
strcpy(section, name);
strcpy_s(section, MAX_SECTION_SIZE, name); //maxi
StaticFileUnloadW(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
return true;
}
@ -131,7 +131,7 @@ static bool _getjit(char* jit, bool jit64)
{
if(!dbggetjit(jit_tmp, jit64 ? x64 : x32, &dummy, NULL))
return false;
strcpy(jit, jit_tmp);
strcpy_s(jit, MAX_SETTING_SIZE, jit_tmp);
}
else // if jit input == NULL: it returns false if there are not an OLD JIT STORED.
{

View File

@ -163,7 +163,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
if(SymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement)
{
char filename[deflen] = "";
strcpy(filename, line.FileName);
strcpy_s(filename, line.FileName);
int len = (int)strlen(filename);
while(filename[len] != '\\' and len != 0)
len--;
@ -568,8 +568,8 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
//TODO: fix this
if(memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr))
curBp.active = true;
strcpy(curBp.mod, list[i].mod);
strcpy(curBp.name, list[i].name);
strcpy_s(curBp.mod, list[i].mod);
strcpy_s(curBp.name, list[i].name);
curBp.singleshoot = list[i].singleshoot;
curBp.slot = slot;
if(curBp.active)

View File

@ -111,7 +111,7 @@ void formathex(char* string)
for(int i = 0, j = 0; i < len; i++)
if(isxdigit(string[i]))
j += sprintf(new_string + j, "%c", string[i]);
strcpy(string, new_string);
strcpy_s(string, len + 1, new_string);
}
void formatdec(char* string)
@ -123,7 +123,7 @@ void formatdec(char* string)
for(int i = 0, j = 0; i < len; i++)
if(isdigit(string[i]))
j += sprintf(new_string + j, "%c", string[i]);
strcpy(string, new_string);
strcpy_s(string, len + 1, new_string);
}
bool FileExists(const char* file)

View File

@ -150,7 +150,7 @@ void argformat(char* cmd)
if(strlen(arguments))
sprintf(cmd, "%s %s", command, arguments);
else
strcpy(cmd, command);
strcpy_s(cmd, deflen, command);
}
/*
@ -173,7 +173,7 @@ int arggetcount(const char* cmd)
arg_count = 1;
char temp_[deflen] = "";
char* temp = temp_ + 1;
strcpy(temp, cmd);
strcpy_s(temp, deflen - 1, cmd);
for(int i = start; i < len; i++)
if(temp[i] == '\\' and (i < len - 1 and temp[i + 1] == '\\'))
{
@ -213,7 +213,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional)
start++;
char temp_[deflen] = "";
char* temp = temp_ + 1;
strcpy(temp, cmd + start);
strcpy_s(temp, deflen - 1, cmd + start);
int len = (int)strlen(temp);
for(int i = 0; i < len; i++)
@ -253,7 +253,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional)
memcpy(temp, new_temp, len + 1);
if(arg_num == 0) //first argument
{
strcpy(arg, temp);
strcpy_s(arg, deflen, temp);
return true;
}
for(int i = 0, j = 0; i < len; i++)
@ -262,7 +262,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional)
j++;
if(j == arg_num)
{
strcpy(arg, temp + i + 1);
strcpy_s(arg, deflen, temp + i + 1);
return true;
}
}

View File

@ -34,11 +34,11 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction
size_t pos = instr.find(" short ");
if(pos != String::npos)
instr.erase(pos, 6);
strcpy(parse.instr, instr.c_str());
strcpy_s(parse.instr, instr.c_str());
if(XEDParseAssemble(&parse) == XEDPARSE_ERROR)
{
if(error)
strcpy(error, parse.error);
strcpy_s(error, MAX_ERROR_SIZE, parse.error);
return false;
}

View File

@ -104,7 +104,7 @@ void bookmarkcacheload(JSON root)
BOOKMARKSINFO curBookmark;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curBookmark.mod, mod);
strcpy_s(curBookmark.mod, mod);
else
*curBookmark.mod = '\0';
curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address"));
@ -123,7 +123,7 @@ void bookmarkcacheload(JSON root)
BOOKMARKSINFO curBookmark;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curBookmark.mod, mod);
strcpy_s(curBookmark.mod, mod);
else
*curBookmark.mod = '\0';
curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address"));

View File

@ -193,8 +193,8 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
bridge->active = bp->active;
bridge->addr = bp->addr;
bridge->enabled = bp->enabled;
strcpy(bridge->mod, bp->mod);
strcpy(bridge->name, bp->name);
strcpy_s(bridge->mod, bp->mod);
strcpy_s(bridge->name, bp->name);
bridge->singleshoot = bp->singleshoot;
switch(bp->type)
{

View File

@ -19,7 +19,7 @@ bool commentset(uint addr, const char* text, bool manual)
}
COMMENTSINFO comment;
comment.manual = manual;
strcpy(comment.text, text);
strcpy_s(comment.text, text);
modnamefromaddr(addr, comment.mod, true);
comment.addr = addr - modbasefromaddr(addr);
const uint key = modhashfromva(addr);
@ -37,7 +37,7 @@ bool commentget(uint addr, char* text)
const CommentsInfo::iterator found = comments.find(modhashfromva(addr));
if(found == comments.end()) //not found
return false;
strcpy(text, found->second.text);
strcpy_s(text, MAX_COMMENT_SIZE, found->second.text);
return true;
}
@ -114,14 +114,14 @@ void commentcacheload(JSON root)
COMMENTSINFO curComment;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curComment.mod, mod);
strcpy_s(curComment.mod, mod);
else
*curComment.mod = '\0';
curComment.addr = (uint)json_hex_value(json_object_get(value, "address"));
curComment.manual = true;
const char* text = json_string_value(json_object_get(value, "text"));
if(text)
strcpy(curComment.text, text);
strcpy_s(curComment.text, text);
else
continue; //skip
const uint key = modhashfromname(curComment.mod) + curComment.addr;
@ -138,7 +138,7 @@ void commentcacheload(JSON root)
COMMENTSINFO curComment;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curComment.mod, mod);
strcpy_s(curComment.mod, mod);
else
*curComment.mod = '\0';
curComment.addr = (uint)json_hex_value(json_object_get(value, "address"));

View File

@ -434,7 +434,7 @@ static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode
if(strstr(text, " bytes - "))
{
Memory<char*> newtext(len + 1, "SymRegisterCallbackProc64:newtext");
strcpy(newtext, text);
strcpy_s(newtext, len + 1, text);
strstr(newtext, " bytes - ")[8] = 0;
GuiSymbolLogAdd(newtext);
suspress = true;
@ -598,7 +598,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
{
wchar_t wszFileName[MAX_PATH] = L"";
if(!DevicePathFromFileHandleW(CreateProcessInfo->hFile, wszFileName, sizeof(wszFileName)))
strcpy(DebugFileName, "??? (GetFileNameFromHandle failed!)");
strcpy_s(DebugFileName, "??? (GetFileNameFromHandle failed!)");
else
strcpy_s(DebugFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str());
}
@ -801,7 +801,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
{
wchar_t wszFileName[MAX_PATH] = L"";
if(!DevicePathFromFileHandleW(LoadDll->hFile, wszFileName, sizeof(wszFileName)))
strcpy(DLLDebugFileName, "??? (GetFileNameFromHandle failed!)");
strcpy_s(DLLDebugFileName, "??? (GetFileNameFromHandle failed!)");
else
strcpy_s(DLLDebugFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str());
}
@ -1126,12 +1126,12 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
//inform GUI we started without problems
GuiSetDebugState(initialized);
//set GUI title
strcpy(szBaseFileName, szFileName);
strcpy_s(szBaseFileName, szFileName);
int len = (int)strlen(szBaseFileName);
while(szBaseFileName[len] != '\\' and len)
len--;
if(len)
strcpy(szBaseFileName, szBaseFileName + len + 1);
strcpy_s(szBaseFileName, szBaseFileName + len + 1);
GuiUpdateWindowTitle(szBaseFileName);
//call plugin callback
PLUG_CB_INITDEBUG initInfo;
@ -1497,35 +1497,35 @@ bool dbgpagerightstostring(DWORD protect, char* rights)
switch(protect & 0xFF)
{
case PAGE_EXECUTE:
strcpy(rights, "E---");
strcpy_s(rights, RIGHTS_STRING_SIZE, "E---");
break;
case PAGE_EXECUTE_READ:
strcpy(rights, "ER--");
strcpy_s(rights, RIGHTS_STRING_SIZE, "ER--");
break;
case PAGE_EXECUTE_READWRITE:
strcpy(rights, "ERW-");
strcpy_s(rights, RIGHTS_STRING_SIZE, "ERW-");
break;
case PAGE_EXECUTE_WRITECOPY:
strcpy(rights, "ERWC");
strcpy_s(rights, RIGHTS_STRING_SIZE, "ERWC");
break;
case PAGE_NOACCESS:
strcpy(rights, "----");
strcpy_s(rights, RIGHTS_STRING_SIZE, "----");
break;
case PAGE_READONLY:
strcpy(rights, "-R--");
strcpy_s(rights, RIGHTS_STRING_SIZE, "-R--");
break;
case PAGE_READWRITE:
strcpy(rights, "-RW-");
strcpy_s(rights, RIGHTS_STRING_SIZE, "-RW-");
break;
case PAGE_WRITECOPY:
strcpy(rights, "-RWC");
strcpy_s(rights, RIGHTS_STRING_SIZE, "-RWC");
break;
}
if(protect & PAGE_GUARD)
strcat(rights, "G");
strcat_s(rights, RIGHTS_STRING_SIZE, "G");
else
strcat(rights, "-");
strcat_s(rights, RIGHTS_STRING_SIZE, "-");
return true;
}
@ -1671,9 +1671,9 @@ bool dbggetdefjit(char* jit_entry)
path[0] = '"';
wchar_t wszPath[MAX_PATH] = L"";
GetModuleFileNameW(GetModuleHandleW(NULL), wszPath, MAX_PATH);
strcpy(&path[1], StringUtils::Utf16ToUtf8(wszPath).c_str());
strcpy_s(&path[1], JIT_ENTRY_DEF_SIZE - 1, StringUtils::Utf16ToUtf8(wszPath).c_str());
strcat(path, ATTACH_CMD_LINE);
strcpy(jit_entry, path);
strcpy_s(jit_entry, JIT_ENTRY_DEF_SIZE, path);
return true;
}

View File

@ -79,14 +79,14 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
argget(*argv, arg3, 2, true);
static char currentfolder[deflen] = "";
strcpy(currentfolder, arg1);
strcpy_s(currentfolder, arg1);
int len = (int)strlen(currentfolder);
while(currentfolder[len] != '\\' and len != 0)
len--;
currentfolder[len] = 0;
if(DirExists(arg3))
strcpy(currentfolder, arg3);
strcpy_s(currentfolder, arg3);
//initialize
wait(WAITID_STOP); //wait for the debugger to stop
waitclear(); //clear waiting flags NOTE: thread-unsafe
@ -180,7 +180,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
bool has_arg2 = argget(*argv, argtype, 2, true);
if(!has_arg2 and (scmp(argname, "ss") or scmp(argname, "long") or scmp(argname, "ud2")))
{
strcpy(argtype, argname);
strcpy_s(argtype, argname);
*argname = 0;
}
_strlwr(argtype);
@ -483,7 +483,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
else if(*arg2 == '0')
restore = false;
else
strcpy(arg3, arg2);
strcpy_s(arg3, arg2);
}
DWORD type = UE_MEMORY;
if(*arg3)
@ -1379,7 +1379,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
const char* szSymbolStore = szDefaultStore;
if(!BridgeSettingGet("Symbols", "DefaultStore", szDefaultStore)) //get default symbol store from settings
{
strcpy(szDefaultStore, "http://msdl.microsoft.com/download/symbols");
strcpy_s(szDefaultStore, "http://msdl.microsoft.com/download/symbols");
BridgeSettingSet("Symbols", "DefaultStore", szDefaultStore);
}
if(argc < 2) //no arguments
@ -1838,7 +1838,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[])
int counter = 0;
uint LoadLibraryA = 0;
char command[50] = "";
char error[256] = "";
char error[MAX_ERROR_SIZE] = "";
GetFullContextDataEx(LoadLibThread, &backupctx);

View File

@ -23,7 +23,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
//zero basicinfo
memset(basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO));
//copy instruction text
strcpy(basicinfo->instruction, disasm->CompleteInstr);
strcpy_s(basicinfo->instruction, disasm->CompleteInstr);
//find immidiat
if(disasm->Instruction.BranchType == 0) //no branch
{
@ -55,7 +55,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
{
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Argument1.Memory.Displacement;
strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
}
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
}
@ -65,7 +65,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
{
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Argument2.Memory.Displacement;
strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
}
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
}
@ -82,14 +82,14 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
{
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
}
else if((disasm->Argument2.ArgType & RELATIVE_) == RELATIVE_)
{
basicinfo->type |= TYPE_MEMORY;
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
}
}

View File

@ -127,9 +127,9 @@ const char* disasmtext(uint addr)
int len = Disasm(&disasm);
static char instruction[INSTRUCT_LENGTH] = "";
if(len == UNKNOWN_OPCODE)
strcpy(instruction, "???");
strcpy_s(instruction, "???");
else
strcpy(instruction, disasm.CompleteInstr);
strcpy_s(instruction, disasm.CompleteInstr);
return instruction;
}
@ -166,7 +166,7 @@ static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG
if(!*argmnemonic)
return false;
arg->memvalue = 0;
strcpy(arg->mnemonic, argmnemonic);
strcpy_s(arg->mnemonic, argmnemonic);
if((argtype & MEMORY_TYPE) == MEMORY_TYPE)
{
arg->type = arg_memory;
@ -233,7 +233,7 @@ void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr)
disasm.VirtualAddr = addr;
disasm.EIP = (UIntPtr)buffer;
int len = Disasm(&disasm);
strcpy(instr->instruction, disasm.CompleteInstr);
strcpy_s(instr->instruction, disasm.CompleteInstr);
if(len == UNKNOWN_OPCODE)
{
instr->instr_size = 1;

View File

@ -126,7 +126,7 @@ void functioncacheload(JSON root)
FUNCTIONSINFO curFunction;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curFunction.mod, mod);
strcpy_s(curFunction.mod, mod);
else
*curFunction.mod = '\0';
curFunction.start = (uint)json_hex_value(json_object_get(value, "start"));
@ -148,7 +148,7 @@ void functioncacheload(JSON root)
FUNCTIONSINFO curFunction;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curFunction.mod, mod);
strcpy_s(curFunction.mod, mod);
else
*curFunction.mod = '\0';
curFunction.start = (uint)json_hex_value(json_object_get(value, "start"));

View File

@ -240,7 +240,7 @@ CMDRESULT cbInstrVarList(int argc, char* argv[])
if(variables[i].alias.length())
continue;
char name[deflen] = "";
strcpy(name, variables[i].name.c_str());
strcpy_s(name, variables[i].name.c_str());
uint value = (uint)variables[i].value.u.value;
if(variables[i].type != VAR_HIDDEN)
{
@ -429,7 +429,7 @@ CMDRESULT cbAssemble(int argc, char* argv[])
bool fillnop = false;
if(argc > 3)
fillnop = true;
char error[256] = "";
char error[MAX_ERROR_SIZE] = "";
int size = 0;
if(!assembleat(addr, argv[2], &size, error, fillnop))
{
@ -1076,9 +1076,9 @@ CMDRESULT cbInstrFind(int argc, char* argv[])
char pattern[deflen] = "";
//remove # from the start and end of the pattern (ODBGScript support)
if(argv[2][0] == '#')
strcpy(pattern, argv[2] + 1);
strcpy_s(pattern, argv[2] + 1);
else
strcpy(pattern, argv[2]);
strcpy_s(pattern, argv[2]);
int len = (int)strlen(pattern);
if(pattern[len - 1] == '#')
pattern[len - 1] = '\0';
@ -1128,9 +1128,9 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
char pattern[deflen] = "";
//remove # from the start and end of the pattern (ODBGScript support)
if(argv[2][0] == '#')
strcpy(pattern, argv[2] + 1);
strcpy_s(pattern, argv[2] + 1);
else
strcpy(pattern, argv[2]);
strcpy_s(pattern, argv[2]);
int len = (int)strlen(pattern);
if(pattern[len - 1] == '#')
pattern[len - 1] = '\0';
@ -1513,7 +1513,7 @@ CMDRESULT cbInstrFindAsm(int argc, char* argv[])
unsigned char dest[16];
int asmsize = 0;
char error[256] = "";
char error[MAX_ERROR_SIZE] = "";
if(!assemble(addr + size / 2, dest, &asmsize, argv[1], error))
{
dprintf("failed to assemble \"%s\" (%s)!\n", argv[1], error);

View File

@ -19,7 +19,7 @@ bool labelset(uint addr, const char* text, bool manual)
}
LABELSINFO label;
label.manual = manual;
strcpy(label.text, text);
strcpy_s(label.text, text);
modnamefromaddr(addr, label.mod, true);
label.addr = addr - modbasefromaddr(addr);
uint key = modhashfromva(addr);
@ -55,7 +55,7 @@ bool labelget(uint addr, char* text)
if(found == labels.end()) //not found
return false;
if(text)
strcpy(text, found->second.text);
strcpy_s(text, MAX_LABEL_SIZE, found->second.text);
return true;
}
@ -132,14 +132,14 @@ void labelcacheload(JSON root)
LABELSINFO curLabel;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curLabel.mod, mod);
strcpy_s(curLabel.mod, mod);
else
*curLabel.mod = '\0';
curLabel.addr = (uint)json_hex_value(json_object_get(value, "address"));
curLabel.manual = true;
const char* text = json_string_value(json_object_get(value, "text"));
if(text)
strcpy(curLabel.text, text);
strcpy_s(curLabel.text, text);
else
continue; //skip
int len = (int)strlen(curLabel.text);
@ -160,7 +160,7 @@ void labelcacheload(JSON root)
LABELSINFO curLabel;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curLabel.mod, mod);
strcpy_s(curLabel.mod, mod);
else
*curLabel.mod = '\0';
curLabel.addr = (uint)json_hex_value(json_object_get(value, "address"));

View File

@ -135,7 +135,7 @@ void loopcacheload(JSON root)
LOOPSINFO curLoop;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curLoop.mod, mod);
strcpy_s(curLoop.mod, mod);
else
*curLoop.mod = '\0';
curLoop.start = (uint)json_hex_value(json_object_get(value, "start"));
@ -158,7 +158,7 @@ void loopcacheload(JSON root)
LOOPSINFO curLoop;
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy(curLoop.mod, mod);
strcpy_s(curLoop.mod, mod);
else
*curLoop.mod = '\0';
curLoop.start = (uint)json_hex_value(json_object_get(value, "start"));

View File

@ -18,7 +18,7 @@ bool modload(uint base, uint size, const char* fullpath)
len--;
if(len)
len++;
strcpy(name, fullpath + len);
strcpy_s(name, fullpath + len);
_strlwr(name);
len = (int)strlen(name);
name[MAX_MODULE_SIZE - 1] = 0; //ignore later characters
@ -30,12 +30,12 @@ bool modload(uint base, uint size, const char* fullpath)
info.hash = modhashfromname(name);
if(len)
{
strcpy(info.extension, name + len);
strcpy_s(info.extension, name + len);
name[len] = 0; //remove extension
}
info.base = base;
info.size = size;
strcpy(info.name, name);
strcpy_s(info.name, name);
//process module sections
HANDLE FileHandle;

View File

@ -141,11 +141,11 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
if(!count)
{
if(error)
strcpy(error, "no patches to apply");
strcpy_s(error, MAX_ERROR_SIZE, "no patches to apply");
return -1;
}
char modname[MAX_MODULE_SIZE] = "";
strcpy(modname, patchlist[0].mod);
strcpy_s(modname, patchlist[0].mod);
//check if all patches are in the same module
for(int i = 0; i < count; i++)
if(_stricmp(patchlist[i].mod, modname))
@ -171,7 +171,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
if(!CopyFileW(szOriginalName, StringUtils::Utf8ToUtf16(szFileName).c_str(), false))
{
if(error)
strcpy(error, "failed to make a copy of the original file (patch target is in use?)");
strcpy_s(error, MAX_ERROR_SIZE, "failed to make a copy of the original file (patch target is in use?)");
return -1;
}
HANDLE FileHandle;
@ -193,11 +193,11 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
if(!StaticFileUnloadW(StringUtils::Utf8ToUtf16(szFileName).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA))
{
if(error)
strcpy(error, "StaticFileUnload failed");
strcpy_s(error, MAX_ERROR_SIZE, "StaticFileUnload failed");
return -1;
}
return patched;
}
strcpy(error, "StaticFileLoad failed");
strcpy_s(error, MAX_ERROR_SIZE, "StaticFileLoad failed");
return -1;
}

View File

@ -315,7 +315,7 @@ bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cb
return false;
PLUG_COMMAND plugCmd;
plugCmd.pluginHandle = pluginHandle;
strcpy(plugCmd.command, command);
strcpy_s(plugCmd.command, command);
if(!dbgcmdnew(command, (CBCOMMAND)cbCommand, debugonly))
return false;
pluginCommandList.push_back(plugCmd);

View File

@ -98,7 +98,7 @@ static bool scriptcreatelinemap(const char* filename)
int add = 0;
while(temp[add] == ' ')
add++;
strcpy(entry.raw, temp + add);
strcpy_s(entry.raw, temp + add);
*temp = 0;
j = 0;
i++;
@ -110,7 +110,7 @@ static bool scriptcreatelinemap(const char* filename)
int add = 0;
while(temp[add] == ' ')
add++;
strcpy(entry.raw, temp + add);
strcpy_s(entry.raw, temp + add);
*temp = 0;
j = 0;
linemap.push_back(entry);
@ -121,7 +121,7 @@ static bool scriptcreatelinemap(const char* filename)
int add = 0;
while(temp[add] == ' ')
add++;
strcpy(entry.raw, temp + add);
strcpy_s(entry.raw, temp + add);
*temp = 0;
j = 0;
linemap.push_back(entry);
@ -132,7 +132,7 @@ static bool scriptcreatelinemap(const char* filename)
if(*temp)
{
memset(&entry, 0, sizeof(entry));
strcpy(entry.raw, temp);
strcpy_s(entry.raw, temp);
linemap.push_back(entry);
}
unsigned int linemapsize = (unsigned int)linemap.size();
@ -152,7 +152,7 @@ static bool scriptcreatelinemap(const char* filename)
{
if(*(comment - 1) == ' ') //space before comment
{
strcpy(line_comment, comment);
strcpy_s(line_comment, comment);
*(comment - 1) = '\0';
}
else //no space before comment
@ -170,7 +170,7 @@ static bool scriptcreatelinemap(const char* filename)
else if(!strncmp(cur.raw, "//", 2)) //comment
{
cur.type = linecomment;
strcpy(cur.u.comment, cur.raw);
strcpy_s(cur.u.comment, cur.raw);
}
else if(cur.raw[rawlen - 1] == ':') //label
{
@ -203,20 +203,20 @@ static bool scriptcreatelinemap(const char* filename)
cur.type = linebranch;
cur.u.branch.type = scriptgetbranchtype(cur.raw);
char newraw[MAX_SCRIPT_LINE_SIZE] = "";
strcpy(newraw, cur.raw);
strcpy_s(newraw, cur.raw);
argformat(newraw);
int len = (int)strlen(newraw);
for(int i = 0; i < len; i++)
if(newraw[i] == ' ')
{
strcpy(cur.u.branch.branchlabel, newraw + i + 1);
strcpy_s(cur.u.branch.branchlabel, newraw + i + 1);
break;
}
}
else
{
cur.type = linecommand;
strcpy(cur.u.command, cur.raw);
strcpy_s(cur.u.command, cur.raw);
}
//append the comment to the raw line again
@ -246,8 +246,8 @@ static bool scriptcreatelinemap(const char* filename)
{
memset(&entry, 0, sizeof(entry));
entry.type = linecommand;
strcpy(entry.raw, "ret");
strcpy(entry.u.command, "ret");
strcpy_s(entry.raw, "ret");
strcpy_s(entry.u.command, "ret");
linemap.push_back(entry);
}
return true;

View File

@ -42,7 +42,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
ADDRINFO addrinfo;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
strcpy_s(label, addrinfo.label);
char module[MAX_MODULE_SIZE] = "";
modnamefromaddr(data, module, false);
char returnToAddr[MAX_COMMENT_SIZE] = "";
@ -58,7 +58,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
*label = 0;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
strcpy_s(label, addrinfo.label);
*module = 0;
modnamefromaddr(data, module, false);
char returnFromAddr[MAX_COMMENT_SIZE] = "";
@ -71,7 +71,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
}
else
sprintf_s(comment->comment, "return to %s from ???", returnToAddr);
strcpy(comment->color, "#ff0000");
strcpy_s(comment->color, "#ff0000");
return true;
}
@ -92,7 +92,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
ADDRINFO addrinfo;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
strcpy_s(label, addrinfo.label);
char module[MAX_MODULE_SIZE] = "";
modnamefromaddr(data, module, false);
char addrInfo[MAX_COMMENT_SIZE] = "";
@ -151,7 +151,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack)
ADDRINFO addrinfo;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
strcpy_s(label, addrinfo.label);
char module[MAX_MODULE_SIZE] = "";
modnamefromaddr(data, module, false);
char returnToAddr[MAX_COMMENT_SIZE] = "";
@ -174,7 +174,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack)
*label = 0;
addrinfo.flags = flaglabel;
if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo))
strcpy(label, addrinfo.label);
strcpy_s(label, addrinfo.label);
*module = 0;
modnamefromaddr(data, module, false);
char returnFromAddr[MAX_COMMENT_SIZE] = "";

View File

@ -18,7 +18,7 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID
memset(&curSymbol, 0, sizeof(SYMBOLINFO));
curSymbol.addr = (duint)pSymInfo->Address;
curSymbol.decoratedSymbol = (char*)BridgeAlloc(len + 1);
strcpy(curSymbol.decoratedSymbol, pSymInfo->Name);
strcpy_s(curSymbol.decoratedSymbol, len + 1, pSymInfo->Name);
curSymbol.undecoratedSymbol = (char*)BridgeAlloc(MAX_SYM_NAME);
if(strstr(pSymInfo->Name, "Ordinal"))
{

View File

@ -18,7 +18,7 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase;
*curInfo.threadName = '\0';
if(!threadNum)
strcpy(curInfo.threadName, "Main Thread");
strcpy_s(curInfo.threadName, "Main Thread");
CriticalSectionLocker locker(LockThreads);
threadList.push_back(curInfo);
threadNum++;

View File

@ -1409,9 +1409,9 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
}
}
else
strcpy(newstring, string);
strcpy_s(newstring, len * 2, string);
Memory<char*> string_(len + 256, "valfromstring:string_");
strcpy(string_, newstring);
strcpy_s(string_, len + 256, newstring);
int add = 0;
bool negative = (*string_ == '-');
while(mathisoperator(string_[add + negative]) > 2)
@ -1463,7 +1463,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
}
}
else
strcpy(newstring, string);
strcpy_s(newstring, len * 2, string);
int read_size = sizeof(uint);
int add = 1;
if(newstring[2] == ':' and isdigit((newstring[1]))) //@n: (number of bytes to read)
@ -2010,7 +2010,7 @@ bool valtostring(const char* string, uint* value, bool silent)
}
}
else
strcpy(newstring, string);
strcpy_s(newstring, len * 2, string);
int read_size = sizeof(uint);
int add = 1;
if(newstring[2] == ':' and isdigit((newstring[1])))
@ -2044,8 +2044,9 @@ bool valtostring(const char* string, uint* value, bool silent)
return false;
}
bool ok = setregister(string, *value);
Memory<char*> regName(strlen(string) + 1, "valtostring:regname");
strcpy(regName, string);
int len = (int)strlen(string);
Memory<char*> regName(len + 1, "valtostring:regname");
strcpy_s(regName, len + 1, string);
_strlwr(regName);
if(strstr(regName, "ip"))
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), false); //update disassembly + register view

View File

@ -201,7 +201,7 @@ static bool cbCommandProvider(char* cmd, int maxlen)
dprintf("command cut at ~%d characters\n", deflen);
newcmd[deflen - 2] = 0;
}
strcpy(cmd, newcmd);
strcpy_s(cmd, deflen, newcmd);
efree(newcmd, "cbCommandProvider:newcmd"); //free allocated command
return true;
}
@ -210,7 +210,7 @@ extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
{
int len = (int)strlen(cmd);
char* newcmd = (char*)emalloc((len + 1) * sizeof(char), "_dbg_dbgcmdexec:newcmd");
strcpy(newcmd, cmd);
strcpy_s(newcmd, len + 1, cmd);
return msgsend(gMsgStack, 0, (uint)newcmd, 0);
}
@ -248,14 +248,14 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
while(dir[len] != '\\')
len--;
dir[len] = 0;
strcpy(alloctrace, dir);
strcpy_s(alloctrace, dir);
PathAppendA(alloctrace, "\\alloctrace.txt");
DeleteFileW(StringUtils::Utf8ToUtf16(alloctrace).c_str());
setalloctrace(alloctrace);
strcpy(dbbasepath, dir); //debug directory
strcpy_s(dbbasepath, dir); //debug directory
PathAppendA(dbbasepath, "db");
CreateDirectoryW(StringUtils::Utf8ToUtf16(dbbasepath).c_str(), 0); //create database directory
strcpy(szSymbolCachePath, dir);
strcpy_s(szSymbolCachePath, dir);
PathAppendA(szSymbolCachePath, "symbols");
SetCurrentDirectoryW(StringUtils::Utf8ToUtf16(dir).c_str());;
gMsgStack = msgallocstack();
@ -265,7 +265,7 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
registercommands();
hCommandLoopThread = CreateThread(0, 0, DbgCommandLoopThread, 0, 0, 0);
char plugindir[deflen] = "";
strcpy(plugindir, dir);
strcpy_s(plugindir, dir);
PathAppendA(plugindir, "plugins");
CreateDirectoryW(StringUtils::Utf8ToUtf16(plugindir).c_str(), 0);
pluginload(plugindir);

View File

@ -181,7 +181,7 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA)
else
info = QString(mod) + " | ";
}
char section[10] = "";
char section[MAX_SECTION_SIZE] = "";
if(DbgFunctions()->SectionFromAddr(parVA, section))
info += "\"" + QString(section) + "\":";
info += QString("%1").arg(parVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();