summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/client.h4
-rw-r--r--source3/libsmb/cliconnect.c22
-rw-r--r--source3/libsmb/clireadwrite.c6
3 files changed, 27 insertions, 5 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 30e0fae874..c6d7b162fc 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -27,7 +27,8 @@
overlap on the wire. This size gives us a nice read/write size, which
will be a multiple of the page size on almost any system */
#define CLI_BUFFER_SIZE (0xFFFF)
-#define CLI_MAX_LARGE_READX_SIZE (127*1024)
+#define CLI_SAMBA_MAX_LARGE_READX_SIZE (127*1024) /* Works for Samba servers */
+#define CLI_WINDOWS_MAX_LARGE_READX_SIZE ((64*1024)-2) /* Windows servers are broken.... */
/*
* These definitions depend on smb.h
@@ -143,6 +144,7 @@ struct cli_state {
unsigned int bufsize;
int initialised;
int win95;
+ BOOL is_samba;
uint32 capabilities;
BOOL dfsroot;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 48885f19d8..6b5de6d143 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -199,6 +199,10 @@ static BOOL cli_session_setup_guest(struct cli_state *cli)
p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), -1, STR_TERMINATE);
p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, STR_TERMINATE);
+ if (strstr(cli->server_type, "Samba")) {
+ cli->is_samba = True;
+ }
+
fstrcpy(cli->user_name, "");
return True;
@@ -263,6 +267,10 @@ static BOOL cli_session_setup_plaintext(struct cli_state *cli, const char *user,
p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, STR_TERMINATE);
fstrcpy(cli->user_name, user);
+ if (strstr(cli->server_type, "Samba")) {
+ cli->is_samba = True;
+ }
+
return True;
}
@@ -408,6 +416,10 @@ static BOOL cli_session_setup_nt1(struct cli_state *cli, const char *user,
p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), -1, STR_TERMINATE);
p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, STR_TERMINATE);
+ if (strstr(cli->server_type, "Samba")) {
+ cli->is_samba = True;
+ }
+
fstrcpy(cli->user_name, user);
if (session_key.data) {
@@ -873,6 +885,10 @@ BOOL cli_session_setup(struct cli_state *cli,
}
}
+ if (strstr(cli->server_type, "Samba")) {
+ cli->is_samba = True;
+ }
+
return True;
}
@@ -1159,9 +1175,9 @@ BOOL cli_negprot(struct cli_state *cli)
if (cli->capabilities & (CAP_LARGE_READX|CAP_LARGE_WRITEX)) {
SAFE_FREE(cli->outbuf);
SAFE_FREE(cli->inbuf);
- cli->outbuf = (char *)SMB_MALLOC(CLI_MAX_LARGE_READX_SIZE+SAFETY_MARGIN);
- cli->inbuf = (char *)SMB_MALLOC(CLI_MAX_LARGE_READX_SIZE+SAFETY_MARGIN);
- cli->bufsize = CLI_MAX_LARGE_READX_SIZE;
+ cli->outbuf = (char *)SMB_MALLOC(CLI_SAMBA_MAX_LARGE_READX_SIZE+SAFETY_MARGIN);
+ cli->inbuf = (char *)SMB_MALLOC(CLI_SAMBA_MAX_LARGE_READX_SIZE+SAFETY_MARGIN);
+ cli->bufsize = CLI_SAMBA_MAX_LARGE_READX_SIZE;
}
} else if (cli->protocol >= PROTOCOL_LANMAN1) {
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 650822bf8e..883bc1260d 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -76,7 +76,11 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
*/
if (cli->capabilities & CAP_LARGE_READX) {
- readsize = CLI_MAX_LARGE_READX_SIZE;
+ if (cli->is_samba) {
+ readsize = CLI_SAMBA_MAX_LARGE_READX_SIZE;
+ } else {
+ readsize = CLI_WINDOWS_MAX_LARGE_READX_SIZE;
+ }
} else {
readsize = (cli->max_xmit - (smb_size+32)) & ~1023;
}