mirror of
https://github.com/samba-team/samba.git
synced 2025-09-09 01:44:21 +03:00
smbd: Simplify fsp_fullbasepath()
Don't call snprintf() if not necessary. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
@@ -2268,17 +2268,10 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
|
|||||||
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen)
|
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char tmp_buf[1] = {'\0'};
|
|
||||||
|
|
||||||
/*
|
if ((buf == NULL) || (buflen == 0)) {
|
||||||
* Don't pass NULL buffer to snprintf (to satisfy static checker)
|
return strlen(fsp->conn->connectpath) + 1 +
|
||||||
* Some callers will call this function with NULL for buf and
|
strlen(fsp->fsp_name->base_name);
|
||||||
* 0 for buflen in order to get length of fullbasepath (without
|
|
||||||
* needing to allocate or write to buf)
|
|
||||||
*/
|
|
||||||
if (buf == NULL) {
|
|
||||||
buf = tmp_buf;
|
|
||||||
SMB_ASSERT(buflen==0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len = snprintf(buf, buflen, "%s/%s", fsp->conn->connectpath,
|
len = snprintf(buf, buflen, "%s/%s", fsp->conn->connectpath,
|
||||||
|
Reference in New Issue
Block a user