未验证 提交 2c59c5ea 编写于 作者: Y Yu Dou 提交者: GitHub

fixed heap-buffer-overflow (#116)

上级 ecd235de
......@@ -72,6 +72,8 @@ int readFromFile(const std::string &fileName, char *&outputData, size_t &fileSiz
fclose(file);
data = (char *)lrealloc(data, readSize + 1);
data[readSize] = '\0';
outputData = data;
fileSize = readSize;
return 0;
......
......@@ -30,8 +30,7 @@ int main()
std::string pidFile = getPidPath();
char buf[1024] = {0};
char *p = buf;
char *p = NULL;
size_t size = 0;
readFromFile(pidFile, p, size);
......@@ -39,5 +38,7 @@ int main()
long long target = 0;
str_to_val(temp, target);
free(p);
EXPECT_EQ(pid, target);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册