summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-06-18 09:25:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:26 -0500
commit864cad1353867a4092e4ba4b46721f91ada64ca9 (patch)
tree20d365433b5e8261f0bbea394dd84a714b00336c /source3
parentc015c69285a3720d611f2f28ad9db6da4e229ed1 (diff)
downloadsamba-864cad1353867a4092e4ba4b46721f91ada64ca9.tar.gz
samba-864cad1353867a4092e4ba4b46721f91ada64ca9.tar.bz2
samba-864cad1353867a4092e4ba4b46721f91ada64ca9.zip
r23537: Revert the inbuf/outbuf part of r23528: This caused the Solaris CC make test
to break. The Solaris CC put the static char InBuffer[TOTAL_BUFFER_SIZE] on an odd address, the malloc'ed one is always aligned. The problem showed up in pull_ucs2, ucs2_align uses the address of InBuffer as an indication whether to bump up the src of the string by one. Unfortunately in the trans calls the data portion is malloced and thus has different alignment guarantees than a static variable. This one is bigger.... Volker (This used to be commit 6affd7818f6981be2a9f44fcf302e7fddb468347)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/process.c64
1 files changed, 54 insertions, 10 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 0e1ad06ed5..3b922af51f 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -25,10 +25,9 @@ uint16 global_smbpid;
extern struct auth_context *negprot_global_auth_context;
extern int smb_echo_count;
-#define TOTAL_BUFFER_SIZE (BUFFER_SIZE+LARGE_WRITEX_HDR_SIZE+SAFETY_MARGIN)
-
-static char InBuffer[TOTAL_BUFFER_SIZE];
-static char OutBuffer[TOTAL_BUFFER_SIZE];
+static char *InBuffer = NULL;
+static char *OutBuffer = NULL;
+static char *current_inbuf = NULL;
/*
* Size of data we can send to client. Set
@@ -209,11 +208,11 @@ BOOL push_deferred_smb_message(uint16 mid,
DEBUG(10,("push_deferred_open_smb_message: pushing message len %u mid %u "
"timeout time [%u.%06u]\n",
- (unsigned int) smb_len(InBuffer)+4, (unsigned int)mid,
+ (unsigned int) smb_len(current_inbuf)+4, (unsigned int)mid,
(unsigned int)end_time.tv_sec,
(unsigned int)end_time.tv_usec));
- return push_queued_message(InBuffer, smb_len(InBuffer)+4,
+ return push_queued_message(current_inbuf, smb_len(current_inbuf)+4,
request_time, end_time,
private_data, priv_len);
}
@@ -1008,6 +1007,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
return(ERROR_DOS(ERRSRV,ERRaccess));
}
+ current_inbuf = inbuf; /* In case we need to defer this message in open... */
outsize = smb_messages[type].fn(conn, inbuf,outbuf,size,bufsize);
}
@@ -1441,6 +1441,47 @@ char *get_OutBuffer(void)
return OutBuffer;
}
+const int total_buffer_size = (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE + SAFETY_MARGIN);
+
+/****************************************************************************
+ Allocate a new InBuffer. Returns the new and old ones.
+****************************************************************************/
+
+static char *NewInBuffer(char **old_inbuf)
+{
+ char *new_inbuf = (char *)SMB_MALLOC(total_buffer_size);
+ if (!new_inbuf) {
+ return NULL;
+ }
+ if (old_inbuf) {
+ *old_inbuf = InBuffer;
+ }
+ InBuffer = new_inbuf;
+#if defined(DEVELOPER)
+ clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, InBuffer, total_buffer_size);
+#endif
+ return InBuffer;
+}
+
+/****************************************************************************
+ Allocate a new OutBuffer. Returns the new and old ones.
+****************************************************************************/
+
+static char *NewOutBuffer(char **old_outbuf)
+{
+ char *new_outbuf = (char *)SMB_MALLOC(total_buffer_size);
+ if (!new_outbuf) {
+ return NULL;
+ }
+ if (old_outbuf) {
+ *old_outbuf = OutBuffer;
+ }
+ OutBuffer = new_outbuf;
+#if defined(DEVELOPER)
+ clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, OutBuffer, total_buffer_size);
+#endif
+ return OutBuffer;
+}
/****************************************************************************
Process commands from the client
@@ -1451,6 +1492,11 @@ void smbd_process(void)
time_t last_timeout_processing_time = time(NULL);
unsigned int num_smbs = 0;
+ /* Allocate the primary Inbut/Output buffers. */
+
+ if ((NewInBuffer(NULL) == NULL) || (NewOutBuffer(NULL) == NULL))
+ return;
+
max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
while (True) {
@@ -1474,8 +1520,7 @@ void smbd_process(void)
run_events(smbd_event_context(), 0, NULL, NULL);
#if defined(DEVELOPER)
- clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE,
- InBuffer, TOTAL_BUFFER_SIZE);
+ clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, InBuffer, total_buffer_size);
#endif
while (!receive_message_or_smb(InBuffer,BUFFER_SIZE+LARGE_WRITEX_HDR_SIZE,select_timeout)) {
@@ -1496,8 +1541,7 @@ void smbd_process(void)
*/
num_echos = smb_echo_count;
- clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE,
- OutBuffer, TOTAL_BUFFER_SIZE);
+ clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, OutBuffer, total_buffer_size);
process_smb(InBuffer, OutBuffer);