[U-Boot] [PATCH v2 1/3] net: Correct size of NFS buffers

Joe Hershberger joe.hershberger at ni.com
Wed Jul 4 00:22:54 UTC 2018


Reported-by: Coverity (CID: 152888)
Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---

Changes in v2:
- Take into account the attributes that could be there
- Tested with v2 and v3

 net/nfs.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/nfs.h b/net/nfs.h
index 6359cd2848..a377c90088 100644
--- a/net/nfs.h
+++ b/net/nfs.h
@@ -42,6 +42,7 @@
  * case, most NFS servers are optimized for a power of 2.
  */
 #define NFS_READ_SIZE	1024	/* biggest power of two that fits Ether frame */
+#define NFS_MAX_ATTRS	26
 
 /* Values for Accept State flag on RPC answers (See: rfc1831) */
 enum rpc_accept_stat {
@@ -55,7 +56,8 @@ enum rpc_accept_stat {
 
 struct rpc_t {
 	union {
-		uint8_t data[2048];
+		uint8_t data[NFS_READ_SIZE + (6 + NFS_MAX_ATTRS) *
+			sizeof(uint32_t)];
 		struct {
 			uint32_t id;
 			uint32_t type;
@@ -72,7 +74,8 @@ struct rpc_t {
 			uint32_t verifier;
 			uint32_t v2;
 			uint32_t astatus;
-			uint32_t data[NFS_READ_SIZE];
+			uint32_t data[NFS_READ_SIZE / sizeof(uint32_t) +
+				NFS_MAX_ATTRS];
 		} reply;
 	} u;
 } __attribute__((packed));
-- 
2.11.0



More information about the U-Boot mailing list