summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-09-24 23:56:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:48 -0500
commit17ab9e8db1ddad310d7e2e565a9109d9a83cce72 (patch)
tree6a5a07927fdb622bcb3bf198284be5333b3fff9d
parentbd5a0ed2f66454b2d298d7fec6a9ede2ca87aef1 (diff)
downloadsamba-17ab9e8db1ddad310d7e2e565a9109d9a83cce72.tar.gz
samba-17ab9e8db1ddad310d7e2e565a9109d9a83cce72.tar.bz2
samba-17ab9e8db1ddad310d7e2e565a9109d9a83cce72.zip
r2610: Even if we only use the fast-path (ascii only) then
we still need to set errno = E2BIG when we overflow. Jeremy. (This used to be commit 7b0560dcccbd44f1f7b67ba1d46f6a5680b6b47c)
-rw-r--r--source3/lib/charcnv.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 40004826b4..0fe1f15ed5 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -394,6 +394,13 @@ size_t convert_string(charset_t from, charset_t to,
#endif
}
}
+ 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 retval;
} else if (from == CH_UCS2 && to != CH_UCS2) {
const unsigned char *p = (const unsigned char *)src;
@@ -423,6 +430,13 @@ size_t convert_string(charset_t from, charset_t to,
#endif
}
}
+ 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 retval;
} else if (from != CH_UCS2 && to == CH_UCS2) {
const unsigned char *p = (const unsigned char *)src;
@@ -452,6 +466,13 @@ size_t convert_string(charset_t from, charset_t to,
#endif
}
}
+ 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 retval;
}