From: Ronnie Sahlberg Date: Mon, 11 Aug 2014 13:15:16 +0000 (-0700) Subject: Merge pull request #97 from rosslagerwall/read-close-crash X-Git-Tag: upstream/1.9.6^2~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a8c840e834942b6eb79d06c0bde77aedfda1836a;hp=9cac8a63409f8b6160d3ad48a65a6358372c4fdd;p=deb_libnfs.git Merge pull request #97 from rosslagerwall/read-close-crash libnfs: Don't perform operations on nfsfh after user callback --- diff --git a/lib/libnfs-sync.c b/lib/libnfs-sync.c index 0fc1094..2851a91 100644 --- a/lib/libnfs-sync.c +++ b/lib/libnfs-sync.c @@ -86,6 +86,10 @@ #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif + #include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" diff --git a/lib/libnfs-zdr.c b/lib/libnfs-zdr.c index c32f661..90abe26 100644 --- a/lib/libnfs-zdr.c +++ b/lib/libnfs-zdr.c @@ -20,6 +20,10 @@ * 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 @@ -28,10 +32,18 @@ #include "aros_compat.h" #endif +#ifdef HAVE_ARPA_INET_H +#include +#endif + #include #include #include +#include #include "libnfs-zdr.h" +#include "libnfs.h" +#include "libnfs-raw.h" +#include "libnfs-private.h" struct opaque_auth _null_auth; diff --git a/lib/libnfs.c b/lib/libnfs.c index 06697e1..c213cad 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -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); } /* diff --git a/lib/socket.c b/lib/socket.c index 3f7f89f..f8db957 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -68,6 +68,7 @@ #include #include #include +#include #include #include "libnfs-zdr.h" #include "libnfs.h" diff --git a/nfs/nfs.c b/nfs/nfs.c index a97d40a..286ced0 100644 --- 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;