summaryrefslogtreecommitdiff
path: root/source4/smb_server
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-09-23 00:51:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:05 -0500
commit9a9dcc7250ccd4544cb797c15b3bc3dfbb760be0 (patch)
tree35948c622b3ba1657fafc7f498c8674c0220e658 /source4/smb_server
parent70c88af1f909a7dcf65293da0ddd1e13ff53a9d5 (diff)
downloadsamba-9a9dcc7250ccd4544cb797c15b3bc3dfbb760be0.tar.gz
samba-9a9dcc7250ccd4544cb797c15b3bc3dfbb760be0.tar.bz2
samba-9a9dcc7250ccd4544cb797c15b3bc3dfbb760be0.zip
r2552: Character set conversion and string handling updates.
The intial motivation for this commit was to merge in some of the bugfixes present in Samba3's chrcnv and string handling code into Samba4. However, along the way I found a lot of unused functions, and decided to do a bit more... The strlen_m code now does not use a fixed buffer, but more work is needed to finish off other functions in str_util.c. These fixed length buffers hav caused very nasty, hard to chase down bugs at some sites. The strupper_m() function has a strupper_talloc() to replace it (we need to go around and fix more uses, but it's a start). Use of these new functions will avoid bugs where the upper or lowercase version of a string is a different length. I have removed the push_*_allocate functions, which are replaced by calls to push_*_talloc. Likewise, pstring and other 'fixed length' wrappers are removed, where possible. I have removed the first ('base pointer') argument, used by push_ucs2, as the Samba4 way of doing things ensures that this is always on an even boundary anyway. (It was used in only one place, in any case). (This used to be commit dfecb0150627b500cb026b8a4932fe87902ca392)
Diffstat (limited to 'source4/smb_server')
-rw-r--r--source4/smb_server/request.c10
-rw-r--r--source4/smb_server/trans2.c4
2 files changed, 9 insertions, 5 deletions
diff --git a/source4/smb_server/request.c b/source4/smb_server/request.c
index d119cadc95..e3121f8398 100644
--- a/source4/smb_server/request.c
+++ b/source4/smb_server/request.c
@@ -379,7 +379,7 @@ size_t req_push_str(struct smbsrv_request *req, char *dest, const char *str, int
dest = req->out.buffer + PTR_DIFF(dest, buf0);
}
- len = push_string(req->out.hdr, dest, str, len, flags);
+ len = push_string(dest, str, len, flags);
grow_size = len + PTR_DIFF(dest, req->out.data);
@@ -435,6 +435,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const
{
int src_len, src_len2, alignment=0;
ssize_t ret;
+ char *dest2;
if (!(flags & STR_NOALIGN) && ucs2_align(req->in.buffer, src, flags)) {
src++;
@@ -465,12 +466,13 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const
src_len2 += 2;
}
- ret = convert_string_talloc(req, CH_UTF16, CH_UNIX, src, src_len2, (const void **)dest);
+ ret = convert_string_talloc(req, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
if (ret == -1) {
*dest = NULL;
return 0;
}
+ *dest = dest2;
return src_len2 + alignment;
}
@@ -492,6 +494,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons
{
int src_len, src_len2;
ssize_t ret;
+ char *dest2;
if (flags & STR_NO_RANGE_CHECK) {
src_len = byte_len;
@@ -512,12 +515,13 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons
src_len2++;
}
- ret = convert_string_talloc(req, CH_DOS, CH_UNIX, src, src_len2, (const void **)dest);
+ ret = convert_string_talloc(req, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
if (ret == -1) {
*dest = NULL;
return 0;
}
+ *dest = dest2;
return src_len2;
}
diff --git a/source4/smb_server/trans2.c b/source4/smb_server/trans2.c
index 48c10b3230..a5033f9b56 100644
--- a/source4/smb_server/trans2.c
+++ b/source4/smb_server/trans2.c
@@ -143,10 +143,10 @@ static size_t trans2_push_data_string(struct smbsrv_request *req,
alignment = 1;
if (dest_len > 0) {
SCVAL(trans->out.data.data + offset, 0, 0);
- ret = push_string(NULL, trans->out.data.data + offset + 1, str->s, dest_len-1, flags);
+ ret = push_string(trans->out.data.data + offset + 1, str->s, dest_len-1, flags);
}
} else {
- ret = push_string(NULL, trans->out.data.data + offset, str->s, dest_len, flags);
+ ret = push_string(trans->out.data.data + offset, str->s, dest_len, flags);
}
/* sometimes the string needs to be terminated, but the length