mirror of
https://github.com/facebook/zstd
synced 2026-08-22 22:32:07 -04:00
Guard mirrored directory name allocation size
This commit is contained in:
parent
5233c58e6c
commit
5e36ed43a6
1 changed files with 7 additions and 1 deletions
|
|
@ -1210,9 +1210,15 @@ static char* mallocAndJoin2Dir(const char *dir1, const char *dir2)
|
|||
assert(dir1 != NULL && dir2 != NULL);
|
||||
{ const size_t dir1Size = strlen(dir1);
|
||||
const size_t dir2Size = strlen(dir2);
|
||||
size_t outDirBufferSize;
|
||||
char *outDirBuffer, *buffer;
|
||||
|
||||
outDirBuffer = (char *) malloc(dir1Size + dir2Size + 2);
|
||||
CONTROL(dir1Size <= (size_t)-1 - dir2Size);
|
||||
outDirBufferSize = dir1Size + dir2Size;
|
||||
CONTROL(outDirBufferSize <= (size_t)-1 - 2);
|
||||
outDirBufferSize += 2;
|
||||
|
||||
outDirBuffer = (char *) malloc(outDirBufferSize);
|
||||
CONTROL(outDirBuffer != NULL);
|
||||
|
||||
memcpy(outDirBuffer, dir1, dir1Size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue