[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v2 2/2] lib/vfscore: fix null pointer dereferences



futimesat allocates buffers via malloc and dereference returned
pointers without NULL checking, causing crashes in OOM situations.

Return EFAULT as this appears to be the most appropriate error code in
this case (the posix definition does include ENOMEM as a possible
error code).

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@xxxxxxxxx>
---
Changed since v1:
 - return EFAULT instead of ENOMEM

diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 7a7a54c..8c80ea6 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1803,6 +1803,12 @@ int futimesat(int dirfd, const char *pathname, const 
struct timeval times[2])
 
        /* build absolute path */
        absolute_path = (char*)malloc(PATH_MAX);
+       if (!absolute_path) {
+               fdrop(fp);
+               error = EFAULT;
+               goto out_errno;
+       }
+
        strlcpy(absolute_path, fp->f_dentry->d_mount->m_path, PATH_MAX);
        strlcat(absolute_path, fp->f_dentry->d_path, PATH_MAX);
 
-- 
2.25.1

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.