libc: fix DIOCGMEDIASIZE handling in VFS plugin

Use the provided argp pointer to store the result but bail out early if
it points into the void.

Issue #2558.
This commit is contained in:
Josef Söntgen 2017-10-26 14:57:47 +02:00 committed by Christian Helmuth
parent 2f32308c0b
commit 3b5a34c163
1 changed files with 6 additions and 1 deletions

View File

@ -719,6 +719,11 @@ int Libc::Vfs_plugin::ioctl(Libc::File_descriptor *fd, int request, char *argp)
case DIOCGMEDIASIZE:
{
if (!argp) {
errno = EINVAL;
return -1;
}
opcode = Opcode::IOCTL_OP_DIOCGMEDIASIZE;
arg = 0;
break;
@ -771,7 +776,7 @@ int Libc::Vfs_plugin::ioctl(Libc::File_descriptor *fd, int request, char *argp)
/* resolve ambiguity with libc type */
using Genode::int64_t;
int64_t *disk_size = (int64_t*)arg;
int64_t *disk_size = (int64_t*)argp;
*disk_size = out.diocgmediasize.size;
return 0;
}