1
0
Fork 0
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:
Jonas 'Sortie' Termansen 2014-05-12 19:09:46 +02:00
parent 0f80611403
commit 812d071481

View file

@ -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 )
{