Skip to content
Snippets Groups Projects
Commit 2afd6f60 authored by Raphael S. Carvalho's avatar Raphael S. Carvalho Committed by Pekka Enberg
Browse files

umount2: Add parameter checks

parent fd2e7bed
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@
*/
#include <sys/stat.h>
#include <sys/param.h>
#include <dirent.h>
#include <limits.h>
......@@ -213,12 +214,18 @@ int
sys_umount2(const char *path, int flags)
{
struct mount *mp;
int error;
int error, pathlen;
DPRINTF(VFSDB_SYSCALL, ("sys_umount: path=%s\n", path));
MOUNT_LOCK();
pathlen = strlen(path);
if (pathlen >= MAXPATHLEN) {
error = ENAMETOOLONG;
goto out;
}
/* Get mount entry */
LIST_FOREACH(mp, &mount_list, m_link) {
if (!strcmp(path, mp->m_path))
......
......@@ -15,6 +15,11 @@ int umount(const char *path)
int umount2(const char *path, int flags)
{
// If called with MNT_EXPIRE and either MNT_DETACH or MNT_FORCE.
if (flags & MNT_EXPIRE && flags & (MNT_DETACH|MNT_FORCE)) {
return libc_error(EINVAL);
}
auto r = sys_umount2(path, flags);
if (r == 0) {
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment