lib/util/charset smb_panic() on incorrect use of strlen_m_ext
authorAndrew Bartlett <abartlet@samba.org>
Wed, 30 Mar 2011 23:32:52 +0000 (10:32 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 31 Mar 2011 00:40:31 +0000 (02:40 +0200)
This may save a developer some time in the future.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Thu Mar 31 02:40:31 CEST 2011 on sn-devel-104

lib/util/charset/util_str.c

index 9aaf651589b7971dec7f3ca29658192ab0e31b7f..f36c91eef35b2a415ad238654c711c015dc6457d 100644 (file)
@@ -145,6 +145,24 @@ _PUBLIC_ size_t strlen_m_ext_handle(struct smb_iconv_handle *ic,
 {
        size_t count = 0;
 
+#ifdef DEVELOPER
+       switch (dst_charset) {
+       case CH_DOS:
+       case CH_UNIX:
+       case CH_DISPLAY:
+               smb_panic("cannot call strlen_m_ext() with a variable dest charset (must be UTF16* or UTF8)");
+       default:
+               break;
+       }
+
+       switch (src_charset) {
+       case CH_UTF16LE:
+       case CH_UTF16BE:
+               smb_panic("cannot call strlen_m_ext() with a UTF16 src charset (must be DOS, UNIX, DISPLAY or UTF8)");
+       default:
+               break;
+       }
+#endif
        if (!s) {
                return 0;
        }