Fixed buffer overflow in CodesToHeader, now dsptool -m creates files correctly as far as I could test

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3484 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-06-17 22:16:48 +00:00
parent 697ce7b1ab
commit a536460067

View File

@ -150,7 +150,7 @@ void CodeToHeader(const std::vector<u16> &code, std::string _filename,
void CodesToHeader(const std::vector<u16> *codes, const std::vector<std::string>* filenames, void CodesToHeader(const std::vector<u16> *codes, const std::vector<std::string>* filenames,
int numCodes, const char *name, std::string &header) int numCodes, const char *name, std::string &header)
{ {
char buffer[1024]; char buffer[0x1000];
int reserveSize = 0; int reserveSize = 0;
for(int i = 0; i < numCodes; i++) for(int i = 0; i < numCodes; i++)
reserveSize += (int)codes[i].size(); reserveSize += (int)codes[i].size();
@ -165,7 +165,6 @@ void CodesToHeader(const std::vector<u16> *codes, const std::vector<std::string>
{ {
std::string filename; std::string filename;
SplitPath(filenames->at(i), NULL, &filename, NULL); SplitPath(filenames->at(i), NULL, &filename, NULL);
// printf("files %s\n", (filenames->at(i).c_str()));
sprintf(buffer, "%s\t\"%s\",\n", buffer, filename.c_str()); sprintf(buffer, "%s\t\"%s\",\n", buffer, filename.c_str());
} }
sprintf(buffer, "%s};\n\n", buffer); sprintf(buffer, "%s};\n\n", buffer);