summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-08-15 20:19:30 +0000
committerAndrew Tridgell <tridge@samba.org>2003-08-15 20:19:30 +0000
commit039e9dc5e609f32b959b6120976e2c59534c659f (patch)
tree79b95c4a4adfaa7e1f439740af3560c792808eaf
parentdbe7b0c402f1d447c6eb4f7f35ad58d2fc2eae49 (diff)
downloadsamba-039e9dc5e609f32b959b6120976e2c59534c659f.tar.gz
samba-039e9dc5e609f32b959b6120976e2c59534c659f.tar.bz2
samba-039e9dc5e609f32b959b6120976e2c59534c659f.zip
- patch to fix a memory leak from metze
- fix a couple of unicode string errors for ascii clients found by RAW- tests (This used to be commit 81c941ba8ae33567d79b4bb0bb5928f5f6077b76)
-rw-r--r--source4/lib/util_sock.c16
-rw-r--r--source4/smbd/process.c2
-rw-r--r--source4/smbd/request.c2
-rw-r--r--source4/smbd/trans2.c8
4 files changed, 9 insertions, 19 deletions
diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c
index 8362290804..95e0c5fe0c 100644
--- a/source4/lib/util_sock.c
+++ b/source4/lib/util_sock.c
@@ -486,22 +486,12 @@ char *get_socket_addr(TALLOC_CTX *mem_ctx, int fd)
struct sockaddr sa;
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
- char *addr_buf;
- addr_buf = talloc_strdup(mem_ctx, "0.0.0.0");
-
- if (fd == -1) {
- return addr_buf;
- }
-
- if (getpeername(fd, &sa, &length) < 0) {
- DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
- return addr_buf;
+ if (fd == -1 || getpeername(fd, &sa, &length) == -1) {
+ return talloc_strdup(mem_ctx, "0.0.0.0");
}
- addr_buf = talloc_strdup(mem_ctx, (char *)inet_ntoa(sockin->sin_addr));
-
- return addr_buf;
+ return talloc_strdup(mem_ctx, (char *)inet_ntoa(sockin->sin_addr));
}
diff --git a/source4/smbd/process.c b/source4/smbd/process.c
index a4e67c7ff1..cf357ef547 100644
--- a/source4/smbd/process.c
+++ b/source4/smbd/process.c
@@ -738,7 +738,7 @@ void init_smbsession(struct event_context *ev, struct model_ops *model_ops, int
/* set an initial client name based on its IP address. This will be replaced with
the netbios name later if it gives us one */
sub_set_remote_machine(strdup(get_socket_addr(smb->mem_ctx, fd)));
- smb->socket.client_addr = talloc_strdup(smb->mem_ctx, get_socket_addr(smb->mem_ctx, fd));
+ smb->socket.client_addr = get_socket_addr(smb->mem_ctx, fd);
/* now initialise a few default values associated with this smb socket */
smb->negotiate.max_send = 0xFFFF;
diff --git a/source4/smbd/request.c b/source4/smbd/request.c
index 47660d8435..3eb849d11f 100644
--- a/source4/smbd/request.c
+++ b/source4/smbd/request.c
@@ -329,7 +329,7 @@ size_t req_push_str(struct request_context *req, char *dest, const char *str, in
const int max_bytes_per_char = 3;
if (!(flags & (STR_ASCII|STR_UNICODE))) {
- flags |= (req->smb->negotiate.client_caps & CAP_UNICODE) ? STR_UNICODE : STR_ASCII;
+ flags |= (req->flags2 & FLAGS2_UNICODE_STRINGS) ? STR_UNICODE : STR_ASCII;
}
if (dest == NULL) {
diff --git a/source4/smbd/trans2.c b/source4/smbd/trans2.c
index b26dbd505a..0838fb04f4 100644
--- a/source4/smbd/trans2.c
+++ b/source4/smbd/trans2.c
@@ -136,7 +136,7 @@ static size_t trans2_push_data_string(struct request_context *req,
}
if (!(flags & (STR_ASCII|STR_UNICODE))) {
- flags |= (req->smb->negotiate.client_caps & CAP_UNICODE) ? STR_UNICODE : STR_ASCII;
+ flags |= (req->flags2 & FLAGS2_UNICODE_STRINGS) ? STR_UNICODE : STR_ASCII;
}
if ((offset&1) && (flags & STR_UNICODE) && !(flags & STR_NOALIGN)) {
@@ -555,21 +555,21 @@ static NTSTATUS trans2_fileinfo_fill(struct request_context *req, struct smb_tra
SSVAL(trans->out.data.data, 62, 0); /* padding */
SIVAL(trans->out.data.data, 64, st->all_info.out.ea_size);
trans2_append_data_string(req, trans, &st->all_info.out.fname,
- 68, 0);
+ 68, STR_UNICODE);
return NT_STATUS_OK;
case RAW_FILEINFO_NAME_INFO:
case RAW_FILEINFO_NAME_INFORMATION:
trans2_setup_reply(req, trans, 2, 4, 0);
SSVAL(trans->out.params.data, 0, 0);
- trans2_append_data_string(req, trans, &st->name_info.out.fname, 0, 0);
+ trans2_append_data_string(req, trans, &st->name_info.out.fname, 0, STR_UNICODE);
return NT_STATUS_OK;
case RAW_FILEINFO_ALT_NAME_INFO:
case RAW_FILEINFO_ALT_NAME_INFORMATION:
trans2_setup_reply(req, trans, 2, 4, 0);
SSVAL(trans->out.params.data, 0, 0);
- trans2_append_data_string(req, trans, &st->alt_name_info.out.fname, 0, 0);
+ trans2_append_data_string(req, trans, &st->alt_name_info.out.fname, 0, STR_UNICODE);
return NT_STATUS_OK;
case RAW_FILEINFO_STREAM_INFO: