summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-03-24 13:00:05 +1100
committerAndrew Tridgell <tridge@samba.org>2011-03-25 04:37:06 +0100
commit5ed2039e1ed44006750fe6e15948bdff241de6ff (patch)
treef6b1d4f6fc3e5d422fab3427a0cd2253d408f8ba /source3
parent4d47493368c0bdfa715814bf5736866a369f00f5 (diff)
downloadsamba-5ed2039e1ed44006750fe6e15948bdff241de6ff.tar.gz
samba-5ed2039e1ed44006750fe6e15948bdff241de6ff.tar.bz2
samba-5ed2039e1ed44006750fe6e15948bdff241de6ff.zip
s3-string: sec_len==-1 support is no longer needed
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/charcnv.c61
1 files changed, 20 insertions, 41 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 1f698c6288..cf6dbdd95a 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -750,15 +750,15 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
return 0;
}
+ if (src_len == (size_t)-1) {
+ smb_panic("sec_len == -1 in pull_ascii_base_talloc");
+ }
+
if (flags & STR_TERMINATE) {
- if (src_len == (size_t)-1) {
- src_len = strlen((const char *)src) + 1;
- } else {
- size_t len = strnlen((const char *)src, src_len);
- if (len < src_len)
- len++;
- src_len = len;
- }
+ size_t len = strnlen((const char *)src, src_len);
+ if (len < src_len)
+ len++;
+ src_len = len;
/* Ensure we don't use an insane length from the client. */
if (src_len >= 1024*1024) {
char *msg = talloc_asprintf(ctx,
@@ -767,14 +767,6 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
(unsigned int)src_len);
smb_panic(msg);
}
- } else {
- /* Can't have an unlimited length
- * non STR_TERMINATE'd.
- */
- if (src_len == (size_t)-1) {
- errno = EINVAL;
- return 0;
- }
}
/* src_len != -1 here. */
@@ -1038,44 +1030,31 @@ static size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
return 0;
}
+ if (src_len == (size_t)-1) {
+ /* no longer used anywhere, but worth checking */
+ smb_panic("sec_len == -1 in pull_ucs2_base_talloc");
+ }
+
if (ucs2_align(base_ptr, src, flags)) {
src = (const void *)((const char *)src + 1);
- if (src_len != (size_t)-1)
- src_len--;
+ src_len--;
ucs2_align_len = 1;
}
if (flags & STR_TERMINATE) {
/* src_len -1 is the default for null terminated strings. */
- if (src_len != (size_t)-1) {
- size_t len = strnlen_w((const smb_ucs2_t *)src,
- src_len/2);
- if (len < src_len/2)
- len++;
- src_len = len*2;
- } else {
- /*
- * src_len == -1 - alloc interface won't take this
- * so we must calculate.
- */
- src_len = (strlen_w((const smb_ucs2_t *)src)+1)*sizeof(smb_ucs2_t);
- }
+ size_t len = strnlen_w((const smb_ucs2_t *)src,
+ src_len/2);
+ if (len < src_len/2)
+ len++;
+ src_len = len*2;
+
/* Ensure we don't use an insane length from the client. */
if (src_len >= 1024*1024) {
smb_panic("Bad src length in pull_ucs2_base_talloc\n");
}
- } else {
- /* Can't have an unlimited length
- * non STR_TERMINATE'd.
- */
- if (src_len == (size_t)-1) {
- errno = EINVAL;
- return 0;
- }
}
- /* src_len != -1 here. */
-
/* ucs2 is always a multiple of 2 bytes */
src_len &= ~1;