Fix buffer overflow in which(1).
This commit is contained in:
parent
0f80611403
commit
812d071481
|
@ -61,7 +61,8 @@ bool Which(const char* cmd, const char* path, bool all)
|
|||
error(1, errno, "malloc");
|
||||
memcpy(dirname, path, len * sizeof(char));
|
||||
dirname[len] = '\0';
|
||||
path += len + 1;
|
||||
if ( (path += len)[0] == ':' )
|
||||
path++;
|
||||
int dirfd = open(dirname, O_RDONLY | O_DIRECTORY);
|
||||
if ( dirfd < 0 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue