Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 642:ebbe3845b46b
Fix a crash when a resource contains non-representable chars
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 30 Dec 2005 12:46:48 +0100 |
parents | f3c05d5fe459 |
children | dd73c3dad815 |
comparison
equal
deleted
inserted
replaced
641:62679532ea55 | 642:ebbe3845b46b |
---|---|
1392 r = strchr(from, '/'); | 1392 r = strchr(from, '/'); |
1393 m = strchr(p, '/'); | 1393 m = strchr(p, '/'); |
1394 if (m++) { | 1394 if (m++) { |
1395 s = from_utf8(m); | 1395 s = from_utf8(m); |
1396 if (s) { | 1396 if (s) { |
1397 // The length should be enough because from_utf should only | 1397 // In some cases the allocated memory size could be too small because |
1398 // reduce the string length | 1398 // when chars cannot be converted strings like "\uxxxx" or "\Uxxxxyyyy" |
1399 // are used. | |
1400 if (strlen(r+1) < strlen(s)) { | |
1401 from = g_realloc(from, 1+m-p+strlen(s)); | |
1402 r = strchr(from, '/'); | |
1403 } | |
1399 strcpy(r+1, s); | 1404 strcpy(r+1, s); |
1400 g_free(s); | 1405 g_free(s); |
1401 } else { | 1406 } else { |
1402 *(r+1) = 0; | 1407 *(r+1) = 0; |
1403 scr_LogPrint(LPRINT_NORMAL, "Decoding of message sender has failed"); | 1408 scr_LogPrint(LPRINT_NORMAL, "Decoding of message sender has failed"); |
1404 scr_LogPrint(LPRINT_LOG, "Decoding of message sender has failed: %s", m); | 1409 scr_LogPrint(LPRINT_LOG, "Decoding of message sender has failed: %s", |
1410 m); | |
1405 } | 1411 } |
1406 } | 1412 } |
1407 } | 1413 } |
1408 | 1414 |
1409 if (!from && packet->type != JPACKET_IQ) { | 1415 if (!from && packet->type != JPACKET_IQ) { |