[pan] fix stuck pan when loading gmane.linux.gentoo.server
- From: Dominique Dumont <ddumont src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan] fix stuck pan when loading gmane.linux.gentoo.server
- Date: Sun, 7 Nov 2021 15:06:38 +0000 (UTC)
commit c7c217e960591896ed4a218704a85655ab2f360a
Author: Dominique Dumont <dod debian org>
Date: Sun Nov 7 15:53:08 2021 +0100
fix stuck pan when loading gmane.linux.gentoo.server
When loading gmane.linux.gentoo.server, pan goes into infinite loop.
Using gsb, I've found that pan is stuck in
__g_mime_iconv_strndup. Since this function is implemented by gmime,
I've removed pan's copy of this function.
I'll cleanup __g_mime_iconv_strdup (without the 'n') once I figure out
what to do with global var like iconv, iconv_inited
pan/usenet-utils/mime-utils.cc | 100 -----------------------------------------
pan/usenet-utils/mime-utils.h | 4 +-
2 files changed, 1 insertion(+), 103 deletions(-)
---
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index bd1a264..9e51abe 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -46,106 +46,6 @@ namespace pan
iconv_t conv(0);
bool iconv_inited(false);
- char *
- __g_mime_iconv_strndup (iconv_t cd, const char *str, size_t n, const char* charset)
- {
- iconv_t ic(0), backup(0);
- if (charset)
- {
- ic = iconv_open ("UTF-8", charset);
- backup = conv;
- conv = ic;
- }
-
- size_t inleft, outleft, converted = 0;
- char *out, *outbuf;
- const char *inbuf;
- size_t outlen;
- int errnosav;
-
- if (cd == (iconv_t) -1 || !iconv_inited)
- return g_strndup (str, n);
-
- outlen = n * 2 + 16;
- out = (char*)g_malloc (outlen + 4);
-
- inbuf = str;
- inleft = n;
-
- do {
- errno = 0;
- outbuf = out + converted;
- outleft = outlen - converted;
-
-#if defined(__NetBSD__)
- converted = iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
-#else
- converted = iconv (cd, (char **) &inbuf, &inleft, &outbuf, &outleft);
-#endif
-
- if (converted != (size_t) -1 && errno == 0) {
- /*
- * EINVAL An incomplete multibyte sequence has been
- * encountered in the input.
- *
- * We'll just have to ignore it...
- */
- break;
- }
-
- if (errno != E2BIG && errno != EILSEQ) {
- errnosav = errno;
- g_free (out);
-
- /* reset the cd */
- iconv (cd, NULL, NULL, NULL, NULL);
-
- errno = errnosav;
-
- return NULL;
- }
-
- /*
- * E2BIG There is not sufficient room at *outbuf.
- *
- * We just need to grow our outbuffer and try again.
- */
- {
- converted = outbuf - out;
- outlen += inleft * 2 + 16;
- out = (char*)g_realloc (out, outlen + 4);
- outbuf = out + converted;
- }
-
- } while (TRUE);
-
- /* flush the iconv conversion */
- while (iconv (cd, NULL, NULL, &outbuf, &outleft) == (size_t) -1) {
- if (errno != E2BIG)
- break;
-
- outlen += 16;
- converted = outbuf - out;
- out = (char*)g_realloc (out, outlen + 4);
- outleft = outlen - converted;
- outbuf = out + converted;
- }
-
- /* Note: not all charsets can be nul-terminated with a single
- nul byte. UCS2, for example, needs 2 nul bytes and UCS4
- needs 4. I hope that 4 nul bytes is enough to terminate all
- multibyte charsets? */
-
- /* nul-terminate the string */
- memset (outbuf, 0, 4);
-
- /* reset the cd */
- iconv (cd, NULL, NULL, NULL, NULL);
-
- if (backup) conv = backup;
-
- return out;
- }
}
namespace
diff --git a/pan/usenet-utils/mime-utils.h b/pan/usenet-utils/mime-utils.h
index a4d992d..5c9843c 100644
--- a/pan/usenet-utils/mime-utils.h
+++ b/pan/usenet-utils/mime-utils.h
@@ -117,11 +117,9 @@ namespace pan
extern iconv_t conv;
extern bool iconv_inited;
- char * __g_mime_iconv_strndup (iconv_t cd, const char *str, size_t n, const char* charset=0);
-
static char * __g_mime_iconv_strdup (iconv_t cd, const char *str, const char* charset=0)
{
- return __g_mime_iconv_strndup(cd, str, strlen(str), charset);
+ return g_mime_iconv_strndup(cd, str, strlen(str));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]