commit a298d6f30aac5a4b25391f3149833027e08d92ba Author: Jacob Welsh AuthorDate: Fri Nov 25 01:28:25 2022 +0000 Commit: Jacob Welsh CommitDate: Fri Nov 25 01:28:25 2022 +0000 Type: portability fix lib-charset: drop iconv tests with utf7 source encoding It's not implemented in musl, and seems unnecessary since this code is used for message decoding & search while utf7 bodies or headers are practically never seen in the wild. Further, the test code is broken because it proceeds to null pointer dereference on "trans" after the initialization failure. diff --git a/src/lib-charset/test-charset.c b/src/lib-charset/test-charset.c index 2f9ba2b26a..ec5840a418 100644 --- a/src/lib-charset/test-charset.c +++ b/src/lib-charset/test-charset.c @@ -70,12 +70,6 @@ static void test_charset_iconv(void) enum charset_result result; } tests[] = { { "ISO-8859-1", "p\xE4\xE4", "p\xC3\xA4\xC3\xA4", CHARSET_RET_OK }, - { "UTF-7", "+AOQA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDkAPYA5AD2AOQA9gDk", - "\xC3\xA4\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4" - "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4" - "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4" - "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4" - "\xC3\xB6\xC3\xA4\xC3\xB6\xC3\xA4", CHARSET_RET_OK } }; string_t *str = t_str_new(128); struct charset_translation *trans; @@ -133,28 +127,6 @@ static void test_charset_iconv_crashes(void) } test_end(); } - -static void test_charset_iconv_utf7_state(void) -{ - struct charset_translation *trans; - string_t *str = t_str_new(32); - unsigned char nextbuf[5+CHARSET_MAX_PENDING_BUF_SIZE+1]; - size_t size; - - test_begin("charset iconv utf7 state"); - test_assert(charset_to_utf8_begin("UTF-7", NULL, &trans) == 0); - size = 2; - test_assert(charset_to_utf8(trans, (const void *)"a+", &size, str) == CHARSET_RET_INCOMPLETE_INPUT); - test_assert(strcmp(str_c(str), "a") == 0); - test_assert(size == 1); - memset(nextbuf, '?', sizeof(nextbuf)); - memcpy(nextbuf, "+AOQ-", 5); - size = sizeof(nextbuf); - test_assert(charset_to_utf8(trans, nextbuf, &size, str) == CHARSET_RET_OK); - test_assert(strcmp(str_c(str), "a\xC3\xA4???????????") == 0); - charset_to_utf8_end(&trans); - test_end(); -} #endif static int convert(const char *charset, const char *path) @@ -218,7 +190,6 @@ int main(int argc, char *argv[]) #ifdef HAVE_ICONV test_charset_iconv, test_charset_iconv_crashes, - test_charset_iconv_utf7_state, #endif NULL };