Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/mod_irc/iconv_erl.c28
2 files changed, 22 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a87d9830d..eb7de7429 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-14 Alexey Shchepin <alexey@sevcom.net>
+
+ * src/mod_irc/iconv_erl.c: Bugfix (thanks to Tomas Janousek)
+
2005-12-13 Alexey Shchepin <alexey@sevcom.net>
* src/win32/ejabberd.nsi: Updated (thanks to Maxim Ryazanov)
diff --git a/src/mod_irc/iconv_erl.c b/src/mod_irc/iconv_erl.c
index 85b898bb3..3698ee977 100644
--- a/src/mod_irc/iconv_erl.c
+++ b/src/mod_irc/iconv_erl.c
@@ -55,27 +55,35 @@ static int iconv_erl_control(ErlDrvData drv_data,
ei_get_type(buf, &index, &i, &size);
stmp = string = malloc(size + 1);
ei_decode_string(buf, &index, string);
-
+
cd = iconv_open(to, from);
- if(cd == (iconv_t) -1)
- {
+ if (cd == (iconv_t) -1) {
cd = iconv_open("ascii", "ascii");
- if(cd == (iconv_t) -1)
- {
- cd = iconv_open("ascii", "ascii");
- }
+ if (cd == (iconv_t) -1) {
+ *rbuf = (char*)(b = driver_alloc_binary(size));
+ memcpy(b->orig_bytes, string, size);
+
+ free(from);
+ free(to);
+ free(string);
+
+ return size;
+ }
}
outleft = avail = 4*size;
inleft = size;
rtmp = rstring = malloc(avail);
- iconv(cd, &stmp, &inleft, &rtmp, &outleft);
+ while (inleft > 0) {
+ if (iconv(cd, &stmp, &inleft, &rtmp, &outleft) == (size_t) -1) {
+ stmp++;
+ inleft--;
+ }
+ }
size = rtmp - rstring;
- //printf("size=%d, res=%s\r\n", size, rstring);
-
*rbuf = (char*)(b = driver_alloc_binary(size));
memcpy(b->orig_bytes, rstring, size);