From 650057cfa881852fba663b10dc1177b9d9da9945 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Tue, 26 Dec 2023 15:57:04 -0800
Subject: [PATCH] Fix CID 471656 in smb_addfile_withlist()

No one's using this function currently (and may never).

It was used back when I was putting archive contents in .ini format in the
files' metadata (now auxdata).
---
 src/smblib/smbfile.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/smblib/smbfile.c b/src/smblib/smbfile.c
index 36f18ab66c..df3e6af39a 100644
--- a/src/smblib/smbfile.c
+++ b/src/smblib/smbfile.c
@@ -361,10 +361,12 @@ int smb_addfile_withlist(smb_t* smb, smbfile_t* file, int storage, const char* e
 
 	if(list != NULL && *list != NULL) {
 		size_t size = strListCount(list) * 1024;
-		auxdata = calloc(1, size);
-		if(auxdata == NULL)
-			return SMB_ERR_MEM;
-		strListCombine(list, auxdata, size - 1, "\r\n");
+		if(size > 0) {
+			auxdata = calloc(1, size);
+			if(auxdata == NULL)
+				return SMB_ERR_MEM;
+			strListCombine(list, auxdata, size - 1, "\r\n");
+		}
 	}
 	result = smb_addfile(smb, file, storage, extdesc, auxdata, path);
 	free(auxdata);
-- 
GitLab