]> git.decadent.org.uk Git - nfs-utils.git/commit
The closeall function is broken in such a way that it almost never nfs-utils-1-2-1-rc1
authorSteve Dickson <steved@redhat.com>
Mon, 22 Jun 2009 14:05:44 +0000 (10:05 -0400)
committerSteve Dickson <steved@redhat.com>
Mon, 22 Jun 2009 14:05:44 +0000 (10:05 -0400)
commit097128d72d1ab4be299bf5fdc0b8e83667fc159b
tree1ca7cdc4078272f9fdbb6b1a54185781e4f44123
parent148503a575534a4050d709045a6c0dcddd565445
The closeall function is broken in such a way that it almost never
closes any file descriptors. It's calling strtol on the text
representation of the file descriptor, and then checking to see if the
value of *endptr is not '\0' before trying to close the file. This check
is wrong.

When strtol returns an endptr that points to a NULL byte, that indicates
that the conversion was completely successful. I believe this check
should instead be requiring that endptr is pointing to '\0' before
closing the fd.

Also, fix up the function to check for conversion errors from strtol. If
one occurs, just skip the close on that entry.

Finally, as Trond pointed out, it's unlikely that readdir will return a
blank string in d_name but that situation wouldn't be detected by the
current code. This patch adds such a check and skips the close if it
occurs.

Reported-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/nfs/closeall.c