From 36055dbb660a1a1086e06b3849e4deb93f2a99ef Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 8 Aug 2018 14:20:58 +0200 Subject: [PATCH] streams_xattr: Make error handling more obvious Do the NULL check right after the alloc call Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/modules/vfs_streams_xattr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 8714007cb8d..0743959e957 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -503,6 +503,11 @@ static int streams_xattr_open(vfs_handle_struct *handle, sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp), xattr_name); + if (sio->xattr_name == NULL) { + errno = ENOMEM; + goto fail; + } + /* * so->base needs to be a copy of fsp->fsp_name->base_name, * making it identical to streams_xattr_recheck(). If the @@ -512,15 +517,15 @@ static int streams_xattr_open(vfs_handle_struct *handle, */ sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp), fsp->fsp_name->base_name); - sio->fsp_name_ptr = fsp->fsp_name; - sio->handle = handle; - sio->fsp = fsp; - - if ((sio->xattr_name == NULL) || (sio->base == NULL)) { + if (sio->base == NULL) { errno = ENOMEM; goto fail; } + sio->fsp_name_ptr = fsp->fsp_name; + sio->handle = handle; + sio->fsp = fsp; + return fakefd; fail: -- 2.47.2