shaharhoch@google.com has uploaded this change for review. ( https://review.gerrithub.io/c/ffilz/nfs-ganesha/+/1201273?usp=email ) Change subject: nfs4_op_readdir: Fix xdr memory allocation ...................................................................... nfs4_op_readdir: Fix xdr memory allocation The memory allocation calculation for XDR encoding of READDIR response wasn't done well. The math as it was didn't really make sense, but the main problem was that if we reach the maximum size response we went over the allocated buffer size and got an error on encoding which caused us to return SERVER_FAULT. The maximum size possible happened when the dir entries filled the allocated buffer exactly, and reached EOF, since in that case we needed to also add a FALSE bool for the last entry. In this case we went over the allocated buffer and got an error. I fixed the memory allocation calculation, and hopefully made it more clear. I also tested it when returning the max response size and did not get an error. Change-Id: Ifd333efe292116e54b0e8089d2ed43916937d1b4 Signed-off-by: Shahar Hochma <shaharhoch@google.com> --- M src/Protocols/NFS/nfs4_op_readdir.c 1 file changed, 22 insertions(+), 15 deletions(-) git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/73/1201273/1 -- To view, visit https://review.gerrithub.io/c/ffilz/nfs-ganesha/+/1201273?usp=email To unsubscribe, or for help writing mail filters, visit https://review.gerrithub.io/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: ffilz/nfs-ganesha Gerrit-Branch: next Gerrit-Change-Id: Ifd333efe292116e54b0e8089d2ed43916937d1b4 Gerrit-Change-Number: 1201273 Gerrit-PatchSet: 1 Gerrit-Owner: shaharhoch@google.com