1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

s3/smbd: cppcheck: Fix ctunullpointer error

Fixes:

source3/smbd/files.c:783: error: ctunullpointer: Null pointer dereference: buf <--[cppcheck]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Noel Power 2019-05-21 13:36:45 +00:00 committed by Noel Power
parent 02017d35f4
commit 6555fa9d8f

View File

@ -778,7 +778,18 @@ const struct GUID *fsp_client_guid(const files_struct *fsp)
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen)
{
int len;
int len = 0;
char tmp_buf[1] = {'\0'};
/*
* Don't pass NULL buffer to snprintf (to satisfy static checker)
* Some callers will call this function with NULL for buf and
* 0 for buflen in order to get length of fullbasepatch (without
* needing to allocate or write to buf)
*/
if (buf == NULL) {
buf = tmp_buf;
}
len = snprintf(buf, buflen, "%s/%s", fsp->conn->connectpath,
fsp->fsp_name->base_name);