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

[[UNIKRAFT PATCH] lib/uk9p, 9pfs: Change file mode from uint8_t to uint32_t



At least UK_9P_OEXCL(0x1000) is uint8_t overflowed. To avoid potential
file mode undesigned truncating, change it uint8_t to uint32_t.

Signed-off-by: Jia He <justin.he@xxxxxxx>
---
 lib/9pfs/9pfs_vnops.c    | 6 +++---
 lib/uk9p/9p.c            | 4 ++--
 lib/uk9p/include/uk/9p.h | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index c81c82a..5a0700c 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -47,10 +47,10 @@
 
 #include "9pfs.h"
 
-static uint8_t uk_9pfs_open_mode_from_posix_flags(unsigned long flags)
+static uint32_t uk_9pfs_open_mode_from_posix_flags(int flags)
 {
-       uint8_t mode = 0;
-       uint8_t flags_rw = flags & (UK_FREAD | UK_FWRITE);
+       uint32_t mode = 0;
+       uint32_t flags_rw = flags & (UK_FREAD | UK_FWRITE);
 
        if (flags_rw == UK_FREAD)
                mode = UK_9P_OREAD;
diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index 9ac7e8a..abddb60 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -266,7 +266,7 @@ out:
        return newfid;
 }
 
-int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
+int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint32_t mode)
 {
        struct uk_9preq *req;
        int rc = 0;
@@ -294,7 +294,7 @@ out:
 }
 
 int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
-               const char *name, uint32_t perm, uint8_t mode,
+               const char *name, uint32_t perm, uint32_t mode,
                const char *extension)
 {
        struct uk_9preq *req;
diff --git a/lib/uk9p/include/uk/9p.h b/lib/uk9p/include/uk/9p.h
index 59d18d9..e91b147 100644
--- a/lib/uk9p/include/uk/9p.h
+++ b/lib/uk9p/include/uk/9p.h
@@ -129,7 +129,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct 
uk_9pfid *fid,
  *   - 0: Successful.
  *   - (< 0): An error occurred.
  */
-int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode);
+int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint32_t mode);
 
 /**
  * Creates a new file with the given name in the directory associated with fid,
@@ -153,7 +153,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, 
uint8_t mode);
  *   - (< 0): An error occurred.
  */
 int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
-               const char *name, uint32_t perm, uint8_t mode,
+               const char *name, uint32_t perm, uint32_t mode,
                const char *extension);
 
 /**
-- 
2.17.1




 


Rackspace

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