util: fixed place where we could look one byte past end of string
authorAndrew Tridgell <tridge@samba.org>
Thu, 22 Oct 2009 00:03:27 +0000 (11:03 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 22 Oct 2009 01:47:54 +0000 (12:47 +1100)
We need to check the length before the value

lib/util/charset/util_unistr.c

index 024dc70acc2748a22b5825b9616f8e46a0d4af5e..045aa4a3e3f4922a4df2c86d13e33425b5d05ae1 100644 (file)
@@ -483,7 +483,7 @@ _PUBLIC_ char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n)
                return NULL;
        }
 
-       while (*src && n--) {
+       while (n-- && *src) {
                size_t c_size;
                codepoint_t c = next_codepoint_convenience(iconv_convenience, src, &c_size);
                src += c_size;