summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-03-25 12:10:41 +1100
committerAndrew Tridgell <tridge@samba.org>2011-03-25 04:37:06 +0100
commit0189087e257f37dc52beebc49967ac763f58dec4 (patch)
tree151551bb97e2770ee561aa5058b79e5b1fcbfc24 /source3/lib
parentf08ec2296edf4cc8f6f5b7a6f3f69975a8724933 (diff)
downloadsamba-0189087e257f37dc52beebc49967ac763f58dec4.tar.gz
samba-0189087e257f37dc52beebc49967ac763f58dec4.tar.bz2
samba-0189087e257f37dc52beebc49967ac763f58dec4.zip
s3-charcnv: fixed converted_size return in fast paths
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/charcnv.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index bcf0941b4f..0be86ef828 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -187,17 +187,21 @@ size_t convert_string_error(charset_t from, charset_t to,
#else
size_t ret = convert_string_internal(from, to, p, slen, q, dlen, converted_size);
if (converted_size) {
- *converted_size += retval;
+ *converted_size = ret + retval;
}
return ret;
#endif
}
}
+ if (converted_size) {
+ *converted_size = retval;
+ }
if (!dlen) {
/* Even if we fast path we should note if we ran out of room. */
if (((slen != (size_t)-1) && slen) ||
((slen == (size_t)-1) && lastp)) {
errno = E2BIG;
+ return (size_t)-1;
}
}
return retval;
@@ -227,17 +231,21 @@ size_t convert_string_error(charset_t from, charset_t to,
#else
size_t ret = convert_string_internal(from, to, p, slen, q, dlen, converted_size);
if (converted_size) {
- *converted_size += retval;
+ *converted_size = ret + retval;
}
return ret;
#endif
}
}
+ if (converted_size) {
+ *converted_size = retval;
+ }
if (!dlen) {
/* Even if we fast path we should note if we ran out of room. */
if (((slen != (size_t)-1) && slen) ||
((slen == (size_t)-1) && lastp)) {
errno = E2BIG;
+ return (size_t)-1;
}
}
return retval;
@@ -267,24 +275,24 @@ size_t convert_string_error(charset_t from, charset_t to,
#else
size_t ret = convert_string_internal(from, to, p, slen, q, dlen, converted_size);
if (converted_size) {
- *converted_size += retval;
+ *converted_size = ret + retval;
}
return ret;
#endif
}
}
if (converted_size) {
- *converted_size += retval;
+ *converted_size = retval;
}
if (!dlen) {
/* Even if we fast path we should note if we ran out of room. */
if (((slen != (size_t)-1) && slen) ||
((slen == (size_t)-1) && lastp)) {
errno = E2BIG;
- return -1;
+ return (size_t)-1;
}
}
- return 0;
+ return retval;
}
#ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS
@@ -303,7 +311,8 @@ size_t convert_string(charset_t from, charset_t to,
switch(errno) {
case EINVAL:
reason="Incomplete multibyte sequence";
- DEBUG(3,("convert_string_internal: Conversion error: %s(%s)\n",reason,src));
+ DEBUG(3,("convert_string_internal: Conversion error: %s(%s)\n",
+ reason, (const char *)src));
return (size_t)-1;
case E2BIG:
{
@@ -325,10 +334,12 @@ size_t convert_string(charset_t from, charset_t to,
}
case EILSEQ:
reason="Illegal multibyte sequence";
- DEBUG(3,("convert_string_internal: Conversion error: %s(%s)\n",reason,src));
+ DEBUG(3,("convert_string_internal: Conversion error: %s(%s)\n",
+ reason, (const char *)src));
return (size_t)-1;
default:
- DEBUG(0,("convert_string_internal: Conversion error: %s(%s)\n",reason,src));
+ DEBUG(0,("convert_string_internal: Conversion error: %s(%s)\n",
+ reason, (const char *)src));
return (size_t)-1;
}
/* smb_panic(reason); */