mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix buffer overflow in which(1).
This commit is contained in:
parent
0f80611403
commit
812d071481
1 changed files with 2 additions and 1 deletions
|
@ -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 a new issue