summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-03-13 02:16:26 +0000
committerJeremy Allison <jra@samba.org>2004-03-13 02:16:26 +0000
commit9a699d74efbcbbb8607c7dea2734d7acb3478896 (patch)
tree4011e11c2e25b3073f10ab9486ac884702639330 /source3/lib
parente4a01b392c518d3706d86d4938ac85707fe275e6 (diff)
downloadsamba-9a699d74efbcbbb8607c7dea2734d7acb3478896.tar.gz
samba-9a699d74efbcbbb8607c7dea2734d7acb3478896.tar.bz2
samba-9a699d74efbcbbb8607c7dea2734d7acb3478896.zip
Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com (MORIYAMA Masayuki).
Don't use nstrings to hold workgroup and netbios names. The problem with them is that MB netbios and workgroup names in unix charset (particularly utf8) may be up to 3x bigger than the name when represented in dos charset (ie. cp932). So go back to using fstrings for these but translate into nstrings (ie. 16 byte length values) for transport on the wire. Jeremy. (This used to be commit 128dec9ae68fd357550de2649d54056ca4fc65cf)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/charcnv.c9
-rw-r--r--source3/lib/util_str.c1
2 files changed, 6 insertions, 4 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 7227a946bc..d38bfdb534 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -839,7 +839,7 @@ size_t push_ascii_nstring(void *dest, const char *src)
}
dest_len = 0;
- for (i = 0; i < buffer_len; i++) {
+ for (i = 0; buffer[i] != 0 && (i < buffer_len); i++) {
unsigned char mb[10];
/* Convert one smb_ucs2_t character at a time. */
size_t mb_len = convert_string(CH_UCS2, CH_DOS, buffer+i, sizeof(smb_ucs2_t), mb, sizeof(mb), False);
@@ -847,6 +847,7 @@ size_t push_ascii_nstring(void *dest, const char *src)
memcpy((char *)dest + dest_len, mb, mb_len);
dest_len += mb_len;
} else {
+ errno = E2BIG;
break;
}
}
@@ -912,9 +913,11 @@ size_t pull_ascii_fstring(char *dest, const void *src)
return pull_ascii(dest, src, sizeof(fstring), -1, STR_TERMINATE);
}
-size_t pull_ascii_nstring(char *dest, const void *src)
+/* When pulling an nstring it can expand into a larger size (dos cp -> utf8). Cope with this. */
+
+size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src)
{
- return pull_ascii(dest, src, sizeof(nstring), sizeof(nstring), STR_TERMINATE);
+ return pull_ascii(dest, src, dest_len, sizeof(nstring), STR_TERMINATE);
}
/**
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index b8cf052862..2be8b7eb64 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1307,7 +1307,6 @@ char *strstr_m(const char *src, const char *findstr)
char *retp;
size_t findstr_len = 0;
- size_t find_w_len;
/* for correctness */
if (!findstr[0]) {