Ticket #20: charcnv.diff
File charcnv.diff, 1.5 KB (added by , 17 years ago) |
---|
-
lib/charcnv.c
1424 1424 /* It cannot occupy more than 4 bytes in UTF16 format */ 1425 1425 uint8_t buf[4]; 1426 1426 smb_iconv_t descriptor; 1427 size_t ilen_max; 1427 1428 size_t ilen_orig; 1428 1429 size_t ilen; 1429 1430 size_t olen_orig; … … 1431 1432 const char *inbuf; 1432 1433 char *outbuf; 1433 1434 1435 *size = 1; 1436 1434 1437 if ((str[0] & 0x80) == 0) { 1435 *size = 1;1436 1438 return (codepoint_t)str[0]; 1437 1439 } 1438 1440 … … 1440 1442 1441 1443 descriptor = conv_handles[CH_UNIX][CH_UTF16LE]; 1442 1444 if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) { 1443 *size = 1;1444 1445 return INVALID_CODEPOINT; 1445 1446 } 1446 1447 1447 *size = 1; 1448 /* We assume that no multi-byte character can take 1449 more than 5 bytes. This is OK as we only 1450 support codepoints up to 1M */ 1451 1452 ilen_max = strnlen( str, 5 ); 1453 1448 1454 ilen_orig = 1; 1449 1455 olen_orig = 2; 1450 1456 while( 1 ) … … 1466 1472 break; 1467 1473 1468 1474 case EINVAL : 1469 /* We assume that no multi-byte character can take 1470 more than 5 bytes. This is OK as we only 1471 support codepoints up to 1M */ 1472 if( ilen_orig < 5 ) 1475 if( ilen_orig < ilen_max ) 1473 1476 ilen_orig++; 1474 1477 else 1475 1478 return INVALID_CODEPOINT;