Null-terminate strings returned from fcntl(F_GETPATH)

This commit is contained in:
Lubos Dolezel 2015-11-03 16:00:24 +01:00
parent 44e8877849
commit 038afe83f0

View File

@ -67,9 +67,15 @@ long sys_fcntl_nocancel(int fd, int cmd, long arg)
case F_GETPATH:
{
char buf[100];
int len;
sprintf(buf, "/proc/self/fd/%d", fd);
return sys_readlink(buf, (char*) arg, MAXPATHLEN);
len = sys_readlink(buf, (char*) arg, MAXPATHLEN);
if (len >= 0)
((char*) arg)[len] = '\0';
return len;
}
// TODO: implement remaining commands
default: