From: Volker Lendecke Date: Thu, 14 Jan 2021 20:57:16 +0000 (+0100) Subject: smbd: Simplify sendfile_short_send() X-Git-Tag: tevent-0.11.0~2001 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3ea181e76206a865d04be836111dd40f462cfff;p=thirdparty%2Fsamba.git smbd: Simplify sendfile_short_send() Allocate 1024 bytes on the stack instead of using calloc Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 8bfe15510c4..c418f39cf3b 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3686,13 +3686,7 @@ ssize_t sendfile_short_send(struct smbXsrv_connection *xconn, nread -= headersize; if (nread < smb_maxcnt) { - char *buf = SMB_CALLOC_ARRAY(char, SHORT_SEND_BUFSIZE); - if (!buf) { - DEBUG(0,("sendfile_short_send: malloc failed " - "for file %s (%s). Terminating\n", - fsp_str_dbg(fsp), strerror(errno))); - return -1; - } + char buf[SHORT_SEND_BUFSIZE] = { 0 }; DEBUG(0,("sendfile_short_send: filling truncated file %s " "with zeros !\n", fsp_str_dbg(fsp))); @@ -3732,7 +3726,6 @@ ssize_t sendfile_short_send(struct smbXsrv_connection *xconn, } nread += to_write; } - SAFE_FREE(buf); } return 0;