git-svn: trunk@2826
Török Edvin authored on 2007/02/22 03:23:16... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Wed Feb 21 17:26:00 CET 2007 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * libclamav/entconv.c: don't cache iconv_open() failures. (bb #329) |
|
4 |
+ |
|
1 | 5 |
Tue Feb 20 21:11:29 CET 2007 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* configure: fix compilation errors on FreeBSD (bb#306) |
... | ... |
@@ -769,6 +769,7 @@ static iconv_t iconv_open_cached(const unsigned char* fromcode) |
769 | 769 |
size_t idx; |
770 | 770 |
const size_t fromcode_len = strlen((const char*)fromcode); |
771 | 771 |
struct element * e; |
772 |
+ iconv_t iconv_struct; |
|
772 | 773 |
|
773 | 774 |
init_iconv_pool_ifneeded(); |
774 | 775 |
cache = cache_get_tls_instance();/* gets TLS iconv pool */ |
... | ... |
@@ -786,6 +787,8 @@ static iconv_t iconv_open_cached(const unsigned char* fromcode) |
786 | 786 |
return cache->tab[e->data]; |
787 | 787 |
} |
788 | 788 |
cli_dbgmsg("iconv not found in cache, for encoding:%s\n",fromcode); |
789 |
+ iconv_struct = iconv_open("UTF-16BE",(const char*)fromcode); |
|
790 |
+ if(iconv_struct != (iconv_t)-1) { |
|
789 | 791 |
idx = cache->last++; |
790 | 792 |
if(idx >= cache->len) { |
791 | 793 |
cache->len += 16; |
... | ... |
@@ -798,10 +801,12 @@ static iconv_t iconv_open_cached(const unsigned char* fromcode) |
798 | 798 |
} |
799 | 799 |
|
800 | 800 |
hashtab_insert(&cache->hashtab, fromcode, fromcode_len, idx); |
801 |
- cache->tab[idx] = iconv_open("UTF-16BE",(const char*)fromcode); |
|
801 |
+ cache->tab[idx] = iconv_struct; |
|
802 | 802 |
cli_dbgmsg("iconv_open(),for:%s -> %p\n",fromcode,(void*)cache->tab[idx]); |
803 | 803 |
return cache->tab[idx]; |
804 | 804 |
} |
805 |
+ return (iconv_t)-1; |
|
806 |
+} |
|
805 | 807 |
|
806 | 808 |
|
807 | 809 |
/* tmp_m_area and conv->out_area are of size maxlen */ |