Fixes ticket #6320.
Unified · Split
| @@ -37,6 +37,9 @@ · 36 unmodified lines | ||
| 37 | 37 | #include "avio_internal.h" |
| 38 | 38 | #include "mpeg.h" |
| 39 | 39 | #include "isom.h" |
| 40 | +#if CONFIG_ICONV | |
| 41 | +#include <iconv.h> | |
| 42 | +#endif | |
| 40 | 43 | |
| 41 | 44 | /* maximum size in which we look for synchronization if |
| 42 | 45 | * synchronization is lost */ |
| @@ -674,6 +677,47 @@ static char *getstr8(const uint8_t **pp, const uint8_t *p_end) · 631 unmodified lines | ||
| 674 | 677 | return NULL; |
| 675 | 678 | if (len > p_end - p) |
| 676 | 679 | return NULL; |
| 680 | +#if CONFIG_ICONV | |
| 681 | + if (len && *p < 0x20) { | |
| 682 | + const char *encodings[] = { | |
| 683 | + "ISO6937", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", | |
| 684 | + "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", | |
| 685 | + "", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "", "", "", "", | |
| 686 | + "", "ISO-10646", "KSC_5601", "GB2312", "UCS-2BE", "UTF-8", "", "", | |
| 687 | + "", "", "", "", "", "", "", "" | |
| 688 | + }; | |
| 689 | + iconv_t cd; | |
| 690 | + char *in, *out; | |
| 691 | + size_t inlen = len - 1, outlen = inlen * 6 + 1; | |
| 692 | + if (len >= 3 && p[0] == 0x10 && !p[1] && p[2] && p[2] <= 0xf && p[2] != 0xc) { | |
| 693 | + char iso8859[12]; | |
| 694 | + snprintf(iso8859, sizeof(iso8859), "ISO-8859-%d", p[2]); | |
| 695 | + inlen -= 2; | |
| 696 | + in = (char *)p + 3; | |
| 697 | + cd = iconv_open("UTF-8", iso8859); | |
| 698 | + } else { | |
| 699 | + in = (char *)p + 1; | |
| 700 | + cd = iconv_open("UTF-8", encodings[*p]); | |
| 701 | + } | |
| 702 | + if (cd == (iconv_t)-1) | |
| 703 | + goto no_iconv; | |
| 704 | + str = out = av_malloc(outlen); | |
| 705 | + if (!str) { | |
| 706 | + iconv_close(cd); | |
| 707 | + return NULL; | |
| 708 | + } | |
| 709 | + if (iconv(cd, &in, &inlen, &out, &outlen) == -1) { | |
| 710 | + iconv_close(cd); | |
| 711 | + av_freep(&str); | |
| 712 | + goto no_iconv; | |
| 713 | + } | |
| 714 | + iconv_close(cd); | |
| 715 | + *out = 0; | |
| 716 | + *pp = p + len; | |
| 717 | + return str; | |
| 718 | + } | |
| 719 | +no_iconv: | |
| 720 | +#endif | |
| 677 | 721 | str = av_malloc(len + 1); |
| 678 | 722 | if (!str) |
| 679 | 723 | return NULL; |
| @@ -33,7 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | // Also please add any ticket numbers that you believe might be affected here |
| 34 | 34 | #define LIBAVFORMAT_VERSION_MAJOR 58 |
| 35 | 35 | #define LIBAVFORMAT_VERSION_MINOR 26 |
| 36 | −#define LIBAVFORMAT_VERSION_MICRO 100 | |
| 36 | +#define LIBAVFORMAT_VERSION_MICRO 101 | |
| 37 | 37 | |
| 38 | 38 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 39 | 39 | LIBAVFORMAT_VERSION_MINOR, \ |