From 9dae2501f1ef21c12385e3abd53c04fdabbed3e9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 Sep 2009 22:22:26 +0200 Subject: s3:vfs_modules: Fix Coverity ID 946: OVERRUN_STATIC Tim, please check! --- source3/modules/vfs_catia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 3c1ab81dc0..d4fef4d14e 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -61,7 +61,7 @@ static bool build_table(struct char_mappings **cmaps, int value) if (!*cmaps) return False; - for (i = 0; i <= MAP_SIZE;i++) { + for (i = 0; i < MAP_SIZE;i++) { (*cmaps)->entry[i][TO_UNIX] = start + i; (*cmaps)->entry[i][TO_WINDOWS] = start + i; } -- cgit From d3a6914e3b3f04b0f2ec2c27995cb7e3975f5d27 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 Sep 2009 22:28:11 +0200 Subject: s3:vfs_catia: Use talloc_zero for simplification --- source3/modules/vfs_catia.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index d4fef4d14e..279ab596fb 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -55,8 +55,7 @@ static bool build_table(struct char_mappings **cmaps, int value) int i; int start = T_START(value); - (*cmaps) = (struct char_mappings *) - TALLOC_ZERO(NULL, sizeof(struct char_mappings)); + (*cmaps) = talloc_zero(NULL, struct char_mappings); if (!*cmaps) return False; -- cgit From e94361e1e29d015e9cdfde47f7163d1dd7bb596a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 Sep 2009 22:47:31 +0200 Subject: s3:vfs_catia: Make some fns static --- source3/modules/vfs_catia.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 279ab596fb..0917812ee2 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -103,8 +103,8 @@ static bool build_ranges(struct char_mappings **cmaps, return True; } -struct share_mapping_entry *get_srt(connection_struct *conn, - struct share_mapping_entry **global) +static struct share_mapping_entry *get_srt(connection_struct *conn, + struct share_mapping_entry **global) { struct share_mapping_entry *share; @@ -119,7 +119,7 @@ struct share_mapping_entry *get_srt(connection_struct *conn, return share; } -struct share_mapping_entry *add_srt(int snum, const char **mappings) +static struct share_mapping_entry *add_srt(int snum, const char **mappings) { char *tmp; -- cgit From f31138ecc778db42b1aa7ce634425a1df663b0eb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 14 Sep 2009 15:06:37 -0700 Subject: Fix bug 6726 - Filename length overwrites oplock request field in cli_nt_create(). Jeremy. --- source3/libsmb/clifile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 696c979802..b15aa8d998 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -2044,7 +2044,7 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - SIVAL(vwv+2, 1, converted_len); + SSVAL(vwv+2, 1, converted_len); subreq = cli_smb_send(state, ev, cli, SMBntcreateX, 0, 24, vwv, talloc_get_size(bytes), bytes); -- cgit From ca2c93b9e578fd9cd565f934b8910d6c738d787b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 14 Sep 2009 15:30:05 -0700 Subject: Fix bug 6494 - Incorrect FileStatus returned in NT_CREATE_ANDX. Lookup the EA and Stream status on CreateX. Jeremy. --- source3/include/smb.h | 9 +++++++++ source3/smbd/nttrans.c | 20 +++++++++++++++++++- source3/smbd/trans2.c | 10 ++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/include/smb.h b/source3/include/smb.h index f8816b6bc5..3c3ced6baf 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1511,6 +1511,15 @@ char *strdup(char *s); /* TCONX Flag (smb_vwv2). */ #define TCONX_FLAG_EXTENDED_RESPONSE 0x8 +/* File Status Flags. See: + +http://msdn.microsoft.com/en-us/library/cc246334(PROT.13).aspx +*/ + +#define NO_EAS 0x1 +#define NO_SUBSTREAMS 0x2 +#define NO_REPARSETAG 0x4 + /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */ #define CAP_RAW_MODE 0x0001 diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 434bf34e40..1b981578e3 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -623,7 +623,25 @@ void reply_ntcreate_and_X(struct smb_request *req) SOFF_T(p,0,file_len); p += 8; if (flags & EXTENDED_RESPONSE_REQUIRED) { - SSVAL(p,2,0x7); + uint16_t file_status = (NO_EAS|NO_SUBSTREAMS|NO_REPARSETAG); + size_t num_names = 0; + unsigned int num_streams; + struct stream_struct *streams = NULL; + + /* Do we have any EA's ? */ + status = get_ea_names_from_file(ctx, conn, fsp, + smb_fname->base_name, NULL, &num_names); + if (NT_STATUS_IS_OK(status) && num_names) { + file_status &= ~NO_EAS; + } + status = SMB_VFS_STREAMINFO(conn, NULL, smb_fname->base_name, ctx, + &num_streams, &streams); + /* There is always one stream, ::$DATA. */ + if (NT_STATUS_IS_OK(status) && num_streams > 1) { + file_status &= ~NO_SUBSTREAMS; + } + TALLOC_FREE(streams); + SSVAL(p,2,file_status); } p += 4; SCVAL(p,0,fsp->is_directory ? 1 : 0); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 73873e09a3..f2c025b6c1 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -207,7 +207,9 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, if (sizeret == 0) { TALLOC_FREE(names); - *pnames = NULL; + if (pnames) { + *pnames = NULL; + } *pnum_names = 0; return NT_STATUS_OK; } @@ -244,7 +246,11 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, names[num_names++] = p; } - *pnames = names; + if (pnames) { + *pnames = names; + } else { + TALLOC_FREE(names); + } *pnum_names = num_names; return NT_STATUS_OK; } -- cgit From 24309bdb2efca36375f3c833f72ebec3908d31fd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 Sep 2009 19:09:54 -0700 Subject: Second part of bug fix for 6606. s3:libsmb: Fix bug 6606 -- short reads in smbclient were not handled --- source3/libsmb/clireadwrite.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3') diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index b6901961d0..6342de484c 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -287,6 +287,12 @@ static void cli_readall_done(struct tevent_req *subreq) return; } + if (received == 0) { + /* EOF */ + tevent_req_done(req); + return; + } + if ((state->received == 0) && (received == state->size)) { /* Ideal case: Got it all in one run */ state->buf = buf; -- cgit From f410d23185f5c81dbc111285ea0ba9daf5fc111d Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Tue, 15 Sep 2009 06:48:49 +0200 Subject: s3: BSD needs sys/sysctl.h included to build properly FreeBSD (and other BSDs, too) need sys/sysctl.h inclueded to use sysctlbyname(). Thanks to Timur Bakeyev for that. --- source3/configure.in | 2 +- source3/lib/fault.c | 5 +++++ source3/param/loadparm.c | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 325575148e..4eaebcab6d 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -652,7 +652,7 @@ AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h) AC_CHECK_HEADERS(limits.h float.h pthread.h libintl.h) AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h) -AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h) +AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h sys/sysctl.h) AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h) AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h) AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h) diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 51fc53bb0d..bf61bb26c4 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -20,6 +20,11 @@ #include "includes.h" +#ifdef HAVE_SYS_SYSCTL_H +#include +#endif + + #ifdef HAVE_SYS_PRCTL_H #include #endif diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index c91f67656b..b278b9616d 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -54,6 +54,10 @@ #include "includes.h" #include "printing.h" +#ifdef HAVE_SYS_SYSCTL_H +#include +#endif + #ifdef HAVE_HTTPCONNECTENCRYPT #include #endif -- cgit