]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify sendfile_short_send()
authorVolker Lendecke <vl@samba.org>
Thu, 14 Jan 2021 20:57:16 +0000 (21:57 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 22 Jan 2021 19:54:38 +0000 (19:54 +0000)
Allocate 1024 bytes on the stack instead of using calloc

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/reply.c

index 8bfe15510c4727db66bc143d34b9b4390ebc1a2d..c418f39cf3bf61a853761dcc96da79835ca25044 100644 (file)
@@ -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;