summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-04-22 02:33:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:27 -0500
commit7b75d2c650cc8dfe8c9d5b9e396afce1cedb0645 (patch)
treefbd6edc9dc938caefee2f6dc04e823b4b69e0563
parentad1fcb7b15f9ea4208d746073c5a00216290a33b (diff)
downloadsamba-7b75d2c650cc8dfe8c9d5b9e396afce1cedb0645.tar.gz
samba-7b75d2c650cc8dfe8c9d5b9e396afce1cedb0645.tar.bz2
samba-7b75d2c650cc8dfe8c9d5b9e396afce1cedb0645.zip
r15162: Patch for bug #3668. Windows has a bug with LARGE_READX
where if you ask for exactly 64k bytes it returns 0. Jeremy. (This used to be commit dcef65acb5bc08ea4b61ef490a518b7e668ff2ee)
-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;
}