>From 417b2771a70f7e44409e7d7cbc63868b42eec287 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 14 Dec 2013 10:45:42 +0100 Subject: [PATCH 1/3] s3:smbd: use PATH_MAX for the buffer passed to full_path_tos() We use this in other places too and it's better than a hardcoded value. Signed-off-by: Stefan Metzmacher --- source3/smbd/files.c | 2 +- source3/smbd/notify.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index ba24eda..5cf037e 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -734,7 +734,7 @@ ssize_t full_path_tos(const char *dir, const char *name, NTSTATUS file_name_hash(connection_struct *conn, const char *name, uint32_t *p_name_hash) { - char tmpbuf[1024]; + char tmpbuf[PATH_MAX]; char *fullpath, *to_free; size_t len; diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index 078bc99..c19982a 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -419,7 +419,7 @@ void notify_fname(connection_struct *conn, uint32 action, uint32 filter, { struct notify_context *notify_ctx = conn->sconn->notify_ctx; char *fullpath, *to_free; - char tmpbuf[1024]; + char tmpbuf[PATH_MAX]; ssize_t len; if (path[0] == '.' && path[1] == '/') { -- 1.7.9.5 >From 056613c60cdc43f739d93a34b3875d25a318f06f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 Dec 2013 23:31:10 +0100 Subject: [PATCH 2/3] s3:lib: avoid talloc_zero_array() in poll_one_fd() Signed-off-by: Stefan Metzmacher --- source3/lib/util_sock.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index a35ae97..12e4ccd 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1490,27 +1490,18 @@ int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res) int poll_one_fd(int fd, int events, int timeout, int *revents) { - struct pollfd *fds; + struct pollfd pfd; int ret; - int saved_errno; - fds = talloc_zero_array(talloc_tos(), struct pollfd, 1); - if (fds == NULL) { - errno = ENOMEM; - return -1; - } - fds[0].fd = fd; - fds[0].events = events; + pfd.fd = fd; + pfd.events = events; - ret = poll(fds, 1, timeout); + ret = poll(&pfd, 1, timeout); /* * Assign whatever poll did, even in the ret<=0 case. */ - *revents = fds[0].revents; - saved_errno = errno; - TALLOC_FREE(fds); - errno = saved_errno; + *revents = pfd.revents; return ret; } -- 1.7.9.5 >From ce1e973a1d487a6e6c14ad8240c147a5da558fe1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Dec 2013 15:02:27 +0100 Subject: [PATCH 3/3] s3:smbd: avoid calling fd_is_readable() without async echo handler Signed-off-by: Stefan Metzmacher --- source3/smbd/process.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 7d9f767..8bd1c2e 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -2383,21 +2383,23 @@ static void smbd_server_connection_read_handler( NTSTATUS status; uint32_t seqnum; - bool from_client; + bool async_echo = lp_async_smb_echo_handler(); + bool from_client = false; - if (lp_async_smb_echo_handler() - && fd_is_readable(sconn->smb1.echo_handler.trusted_fd)) { - /* - * This is the super-ugly hack to prefer the packets - * forwarded by the echo handler over the ones by the - * client directly - */ - fd = sconn->smb1.echo_handler.trusted_fd; + if (async_echo) { + if (fd_is_readable(sconn->smb1.echo_handler.trusted_fd)) { + /* + * This is the super-ugly hack to prefer the packets + * forwarded by the echo handler over the ones by the + * client directly + */ + fd = sconn->smb1.echo_handler.trusted_fd; + } } from_client = (sconn->sock == fd); - if (from_client) { + if (async_echo && from_client) { smbd_lock_socket(sconn); if (!fd_is_readable(fd)) { @@ -2416,7 +2418,7 @@ static void smbd_server_connection_read_handler( &inbuf_len, &seqnum, !from_client /* trusted channel */); - if (from_client) { + if (async_echo && from_client) { smbd_unlock_socket(sconn); } -- 1.7.9.5