[haiku-commits] haiku: hrev54709 - src/system/kernel/fs

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Nov 2020 15:01:21 -0500 (EST)

hrev54709 adds 1 changeset to branch 'master'
old head: dad52bddc7d6b4b7e4c8591939ee3ea37e0e08a3
new head: a756a8ad1bc08030f076952e44f5e8b0e0c8d8d7
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=a756a8ad1bc0+%5Edad52bddc7d6

----------------------------------------------------------------------------

a756a8ad1bc0: kernel/fs: On write, relax address check on 0 length and NULL ptr
  
  * IEEE Std 1003.1-2017, read, write
  * golang performs a write of 0 length with a NULL buffer to
    "create" an empty file. We return BAD_ADDRESS for this.
  * If condition above occurs, continue as a length of 0 means
    we won't read the passed buffer.
  
  Change-Id: I8718abb92f5865a7b6f4fb7f2b74f803497ebef0
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/3285
  Reviewed-by: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54709
Commit:      a756a8ad1bc08030f076952e44f5e8b0e0c8d8d7
URL:         https://git.haiku-os.org/haiku/commit/?id=a756a8ad1bc0
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Fri Oct  2 20:15:52 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sun Nov 15 20:00:55 2020 UTC

----------------------------------------------------------------------------

1 file changed, 6 insertions(+), 3 deletions(-)
src/system/kernel/fs/fd.cpp | 9 ++++++---

----------------------------------------------------------------------------

diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp
index a15b3b6e3b..607d416ba0 100644
--- a/src/system/kernel/fs/fd.cpp
+++ b/src/system/kernel/fs/fd.cpp
@@ -731,9 +731,6 @@ common_close(int fd, bool kernel)
 static ssize_t
 common_user_io(int fd, off_t pos, void* buffer, size_t length, bool write)
 {
-       if (!IS_USER_ADDRESS(buffer))
-               return B_BAD_ADDRESS;
-
        if (pos < -1)
                return B_BAD_VALUE;
 
@@ -758,6 +755,12 @@ common_user_io(int fd, off_t pos, void* buffer, size_t 
length, bool write)
                return B_BAD_VALUE;
        }
 
+       if (length == 0)
+               return 0;
+
+       if (!IS_USER_ADDRESS(buffer))
+               return B_BAD_ADDRESS;
+
        SyscallRestartWrapper<status_t> status;
 
        if (write)


Other related posts:

  • » [haiku-commits] haiku: hrev54709 - src/system/kernel/fs - Adrien Destugues