s4/ntvfs/cifs: cppcheck: squash nullPointer: Possible null pointer dereference
authorNoel Power <noel.power@suse.com>
Wed, 22 May 2019 09:29:18 +0000 (09:29 +0000)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 4 Jun 2019 22:13:07 +0000 (22:13 +0000)
Fix the following cppcheck warnings

/home/samba/samba-pidl/source4/ntvfs/cifs/vfs_cifs.c:604: warning: nullPointer: Possible null pointer dereference: file <--[cppcheck]
/home/samba/samba-pidl/source4/ntvfs/cifs/vfs_cifs.c:605: warning: nullPointer: Possible null pointer dereference: file <--[cppcheck]
/home/samba/samba-pidl/source4/ntvfs/cifs/vfs_cifs.c:648: warning: nullPointer: Possible null pointer dereference: file <--[cppcheck]
/home/samba/samba-pidl/source4/ntvfs/cifs/vfs_cifs.c:649: warning: nullPointer: Possible null pointer dereference: file <--[cppcheck]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/ntvfs/cifs/vfs_cifs.c

index d88c034c6f2ad9e5e9256138d75ce954b409c39a..4e11568ea464d646d4f21e42f01eea972c2fb05b 100644 (file)
@@ -598,9 +598,15 @@ static void async_open(struct smbcli_request *c_req)
        struct cvfs_file *f = async->f;
        union smb_open *io = async->parms;
        union smb_handle *file;
+       if (f == NULL) {
+               goto failed;
+       }
        talloc_free(async);
        req->async_states->status = smb_raw_open_recv(c_req, req, io);
        SMB_OPEN_OUT_FILE(io, file);
+       if (file == NULL) {
+               goto failed;
+       }
        f->fnum = file->fnum;
        file->ntvfs = NULL;
        if (!NT_STATUS_IS_OK(req->async_states->status)) goto failed;
@@ -645,6 +651,9 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
                NT_STATUS_NOT_OK_RETURN(status);
 
                SMB_OPEN_OUT_FILE(io, file);
+               if (file == NULL) {
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
                f->fnum = file->fnum;
                file->ntvfs = NULL;
                status = ntvfs_handle_set_backend_data(f->h, p->ntvfs, f);