dCache / nfs4j

Pure Java NFSv3 and NFSv4.2 implementation
Other
240 stars 76 forks source link

fix NPE after READDIR in nfs3, enable console logging in dev/debug #8

Closed radai-rosenblatt closed 10 years ago

radai-rosenblatt commented 10 years ago

as discussed in https://github.com/dCache/jpnfs/issues/5, there are 3 scenarios that result in an NPE in READDIR:

  1. vfs implementation returns an empty list of directory entris (technically legal?)
  2. client issues read request with very small "count" value, leaving not enough space for even a single entry
  3. client attempts a 2nd read request using the cookie+verifier values from the last entry in a previous complete (eof=true) read request

this commit attempts to address all 3, complete with test cases. there are 2 significant changes:

  1. execute the entry-list-writing code only if server intends to write actual entries (if startValue < dirList.size()) - this way res.resok.reply.entries is not initialized if no entries are to be written
  2. when hitting the client-provided size limit, check to see if any entries have actually been written, and clear res.resok.reply.entries if not
radai-rosenblatt commented 10 years ago

simply changing to if (startValue >= dirList,size()) would return BAD_COOKIE for an empty directory (startValue=0 == dirList.size()=0).

instead i moved the BAD_COOKIE check to the cookie path (startValue != 0, line 869) and added a check for dirList.isEmpty() before allocating reply.entries

dcache-ci commented 10 years ago

Can one of the admins verify this patch?

kofemann commented 10 years ago

add to whitelist