Merge pull request #97 from rosslagerwall/read-close-crash
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 11 Aug 2014 13:15:16 +0000 (06:15 -0700)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 11 Aug 2014 13:15:16 +0000 (06:15 -0700)
libnfs: Don't perform operations on nfsfh after user callback

lib/libnfs-sync.c
lib/libnfs-zdr.c
lib/libnfs.c
lib/socket.c
nfs/nfs.c

index 0fc10944f86e6572d13998958887721283b18dad..2851a9109f4aeb625c6f171e8fd9a71afc446bc7 100644 (file)
 #include <sys/sockio.h>
 #endif
 
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
 #include "libnfs-zdr.h"
 #include "libnfs.h"
 #include "libnfs-raw.h"
index c32f661fc86cc8170940673e4b10c3d4deebce2d..90abe26d0f26e8184b452cb29703b67acd8799f0 100644 (file)
  * i.e. zdrmem_create() buffers.
  * It aims to be compatible with normal rpcgen generated functions.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #ifdef WIN32
 #include "win32_compat.h"
 #endif
 #include "aros_compat.h"
 #endif
 
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <unistd.h>
 #include "libnfs-zdr.h"
+#include "libnfs.h"
+#include "libnfs-raw.h"
+#include "libnfs-private.h"
 
 struct opaque_auth _null_auth;
 
index 06697e10c62311d7d59a0e88f19e837e044e4531..c213caddb20967361549c1b0eca28e6c1ae65822 100644 (file)
@@ -73,6 +73,7 @@
 #include <string.h>
 #include <assert.h>
 #include <errno.h>
+#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -2777,7 +2778,7 @@ static void nfs_create_trunc_cb(struct rpc_context *rpc, int status, void *comma
 {
        struct nfs_cb_data *data = private_data;
        struct nfs_context *nfs = data->nfs;
-       struct nfsfh *nfsfh;
+       struct nfsfh *nfsfh = data->nfsfh;
        SETATTR3res *res;
 
        assert(rpc->magic == RPC_CONTEXT_MAGIC);
@@ -2804,7 +2805,7 @@ static void nfs_create_trunc_cb(struct rpc_context *rpc, int status, void *comma
                return;
        }
 
-       data->cb(0, nfs, data->nfsfh, data->private_data);
+       data->cb(0, nfs, nfsfh, data->private_data);
        free_nfs_cb_data(data);
 }
 
@@ -3994,12 +3995,12 @@ int nfs_chmod_async_internal(struct nfs_context *nfs, const char *path, int no_f
 
 int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data)
 {
-       return nfs_chown_async_internal(nfs, path, 0, mode, cb, private_data);
+       return nfs_chmod_async_internal(nfs, path, 0, mode, cb, private_data);
 }
 
 int nfs_lchmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data)
 {
-       return nfs_chown_async_internal(nfs, path, 1, mode, cb, private_data);
+       return nfs_chmod_async_internal(nfs, path, 1, mode, cb, private_data);
 }
 
 /*
index 3f7f89f90c9a368dc5ff6c48c0ab87f790d4e096..f8db957e0bb600510fcba27afc06dd04b2145c1b 100644 (file)
@@ -68,6 +68,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <time.h>
 #include <sys/types.h>
 #include "libnfs-zdr.h"
 #include "libnfs.h"
index a97d40ab7d543e6d8a37ce97b7a5d5665a3dd852..286ced0af314f6fcad52b95bc8961ed0fa5b7192 100644 (file)
--- a/nfs/nfs.c
+++ b/nfs/nfs.c
@@ -86,7 +86,7 @@ int nfsstat3_to_errno(int error)
        case NFS3ERR_ROFS:        return -EROFS; break;
        case NFS3ERR_MLINK:       return -EMLINK; break;
        case NFS3ERR_NAMETOOLONG: return -ENAMETOOLONG; break;
-       case NFS3ERR_NOTEMPTY:    return -EEXIST; break;
+       case NFS3ERR_NOTEMPTY:    return -ENOTEMPTY; break;
        case NFS3ERR_DQUOT:       return -ERANGE; break;
        case NFS3ERR_STALE:       return -EIO; break;
        case NFS3ERR_REMOTE:      return -EIO; break;