r2610: Even if we only use the fast-path (ascii only) then
authorJeremy Allison <jra@samba.org>
Fri, 24 Sep 2004 23:56:22 +0000 (23:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:48 +0000 (10:52 -0500)
we still need to set errno = E2BIG when we overflow.
Jeremy.
(This used to be commit 7b0560dcccbd44f1f7b67ba1d46f6a5680b6b47c)

source3/lib/charcnv.c

index 40004826b4a209a3de67129932f2c90918b12797..0fe1f15ed5de745cc86224e62f9792bdf6caf21a 100644 (file)
@@ -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;
        }