From c51f367f7990edbbcc23674d11edcd2e6f4a27bc Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Sat, 6 Jan 2024 19:03:26 -0500 Subject: [PATCH 1/7] ASAN: process_spu copies overlapping buffers --- src/lib_ccx/dvd_subtitle_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_ccx/dvd_subtitle_decoder.c b/src/lib_ccx/dvd_subtitle_decoder.c index d8a89ea1c..2269ab439 100644 --- a/src/lib_ccx/dvd_subtitle_decoder.c +++ b/src/lib_ccx/dvd_subtitle_decoder.c @@ -384,7 +384,7 @@ int process_spu(struct lib_cc_decode *dec_ctx, unsigned char *buff, int length, if (ctx->append == 1) { - memcpy(ctx->buffer + ctx->len, buff, length); + memmove(ctx->buffer + ctx->len, buff, length); ctx->len += length; ctx->append = 0; } From e9cc967879aed69332008eb84b9d73cc362786a8 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Sat, 6 Jan 2024 21:00:07 -0500 Subject: [PATCH 2/7] ocr_bitmap: Make sure there is enough room for the last_font_tag --- src/lib_ccx/ocr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib_ccx/ocr.c b/src/lib_ccx/ocr.c index 9571030d5..8e544e058 100644 --- a/src/lib_ccx/ocr.c +++ b/src/lib_ccx/ocr.c @@ -616,6 +616,7 @@ char *ocr_bitmap(void *arg, png_color *palette, png_byte *alpha, unsigned char * // realloc if memory allocated may be not enough int length_needed = (new_text_out_iter - new_text_out) + (line_end - line_start) + + (last_font_tag_end ? (last_font_tag_end - last_font_tag) : 0) + length_closing_font + 32; if (length_needed > length) From fc8dfa64f570a8a8b92d9443fd3a73e004b1dd06 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Sat, 6 Jan 2024 21:04:56 -0500 Subject: [PATCH 3/7] Update CHANGES.TXT --- docs/CHANGES.TXT | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index 5471ea1a9..f68ff499f 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -21,6 +21,7 @@ - Fix: Repeated values for enums - Cleanup: Remove the (unmaintained) Nuklear GUI code - Cleanup: Reduce the amount of Windows build options in the project file +- Fix: fatal out of memory error extracting from a VOB PS 0.94 (2021-12-14) ----------------- From de88c638e316ab928996f802fc842f1ecee8ca30 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Tue, 31 Dec 2024 18:00:49 -0500 Subject: [PATCH 4/7] Baseline formatting fixes --- src/lib_ccx/asf_functions.c | 2 +- src/lib_ccx/ccx_decoders_common.c | 2 +- src/lib_ccx/ccx_encoders_spupng.c | 6 +++++- src/lib_ccx/dvb_subtitle_decoder.c | 16 ++++++++-------- src/lib_ccx/general_loop.c | 2 +- src/lib_ccx/hardsubx_decoder.c | 2 +- src/rust/src/decoder/encoding.rs | 4 ++-- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/lib_ccx/asf_functions.c b/src/lib_ccx/asf_functions.c index dd10fd1d7..fcf66788e 100644 --- a/src/lib_ccx/asf_functions.c +++ b/src/lib_ccx/asf_functions.c @@ -561,7 +561,7 @@ int asf_get_more_data(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) dbg_print(CCX_DMT_PARSE, "Number of data packets: %ld\n", (long)asf_data_container.TotalDataPackets); reentry = 0; // Make sure we read the Data Packet Headers - } // End of if (firstcall) + } // End of if (firstcall) firstcall = 0; // Start loop over Data Packets diff --git a/src/lib_ccx/ccx_decoders_common.c b/src/lib_ccx/ccx_decoders_common.c index c9e639af6..7961506f6 100644 --- a/src/lib_ccx/ccx_decoders_common.c +++ b/src/lib_ccx/ccx_decoders_common.c @@ -219,7 +219,7 @@ int do_cb(struct lib_cc_decode *ctx, unsigned char *cc_block, struct cc_subtitle default: fatal(CCX_COMMON_EXIT_BUG_BUG, "In do_cb: Impossible value for cc_type, Please file a bug report on GitHub.\n"); } // switch (cc_type) - } // cc_valid + } // cc_valid else { dbg_print(CCX_DMT_CBRAW, " .. .. ..\n"); diff --git a/src/lib_ccx/ccx_encoders_spupng.c b/src/lib_ccx/ccx_encoders_spupng.c index b3ca5fa0b..c3c19cff0 100644 --- a/src/lib_ccx/ccx_encoders_spupng.c +++ b/src/lib_ccx/ccx_encoders_spupng.c @@ -704,7 +704,11 @@ uint32_t *utf8_to_utf32(char *src) } // Convert big-endian and little-endian -#define BigtoLittle32(A) ((((uint32_t)(A)&0xff000000) >> 24) | (((uint32_t)(A)&0x00ff0000) >> 8) | (((uint32_t)(A)&0x0000ff00) << 8) | (((uint32_t)(A)&0x000000ff) << 24)) +#define BigtoLittle32(A) ( \ + (((uint32_t)(A) & 0xff000000) >> 24) | \ + (((uint32_t)(A) & 0x00ff0000) >> 8) | \ + (((uint32_t)(A) & 0x0000ff00) << 8) | \ + (((uint32_t)(A) & 0x000000ff) << 24)) // Generate PNG file from an UTF-8 string (str) // PNG file will be stored at output diff --git a/src/lib_ccx/dvb_subtitle_decoder.c b/src/lib_ccx/dvb_subtitle_decoder.c index ad1266834..ba3c07506 100644 --- a/src/lib_ccx/dvb_subtitle_decoder.c +++ b/src/lib_ccx/dvb_subtitle_decoder.c @@ -39,20 +39,20 @@ #define YUV_TO_RGB1_CCIR(cb1, cr1) \ { \ - cb = (cb1)-128; \ - cr = (cr1)-128; \ + cb = (cb1) - 128; \ + cr = (cr1) - 128; \ r_add = FIX(1.40200 * 255.0 / 224.0) * cr + ONE_HALF; \ g_add = -FIX(0.34414 * 255.0 / 224.0) * cb - FIX(0.71414 * 255.0 / 224.0) * cr + \ ONE_HALF; \ b_add = FIX(1.77200 * 255.0 / 224.0) * cb + ONE_HALF; \ } -#define YUV_TO_RGB2_CCIR(r, g, b, y1) \ - { \ - y = ((y1)-16) * FIX(255.0 / 219.0); \ - r = cm[(y + r_add) >> SCALEBITS]; \ - g = cm[(y + g_add) >> SCALEBITS]; \ - b = cm[(y + b_add) >> SCALEBITS]; \ +#define YUV_TO_RGB2_CCIR(r, g, b, y1) \ + { \ + y = ((y1) - 16) * FIX(255.0 / 219.0); \ + r = cm[(y + r_add) >> SCALEBITS]; \ + g = cm[(y + g_add) >> SCALEBITS]; \ + b = cm[(y + b_add) >> SCALEBITS]; \ } #define times4(x) x, x, x, x diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index fc9b59c37..109bae775 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -993,7 +993,7 @@ int general_loop(struct lib_ccx_ctx *ctx) enum ccx_stream_mode_enum stream_mode; struct demuxer_data *datalist = NULL; struct demuxer_data *data_node = NULL; - int (*get_more_data)(struct lib_ccx_ctx * c, struct demuxer_data * *d); + int (*get_more_data)(struct lib_ccx_ctx *c, struct demuxer_data **d); int ret; int caps = 0; diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c index b5dfaec4f..08aaf1d23 100644 --- a/src/lib_ccx/hardsubx_decoder.c +++ b/src/lib_ccx/hardsubx_decoder.c @@ -552,7 +552,7 @@ void process_hardsubx_linear_frames_and_normal_subs(struct lib_hardsubx_ctx *har enum ccx_stream_mode_enum stream_mode; struct demuxer_data *datalist = NULL; struct demuxer_data *data_node = NULL; - int (*get_more_data)(struct lib_ccx_ctx * c, struct demuxer_data * *d); + int (*get_more_data)(struct lib_ccx_ctx *c, struct demuxer_data **d); int ret; int caps = 0; diff --git a/src/rust/src/decoder/encoding.rs b/src/rust/src/decoder/encoding.rs index 2671cedd9..8fabd585a 100644 --- a/src/rust/src/decoder/encoding.rs +++ b/src/rust/src/decoder/encoding.rs @@ -9,8 +9,8 @@ /// 80-9F -> Characters that are in the G2 group in 60-7F /// (there are several blank characters here, that's OK) /// A0-FF -> Group G1 as is - non-English characters and symbols - -// NOTE: Same as `lib_ccx/ccx_decoder_708_encoding.c` file +/// +/// NOTE: Same as `lib_ccx/ccx_decoder_708_encoding.c` file #[no_mangle] pub extern "C" fn dtvcc_get_internal_from_G0(g0_char: u8) -> u8 { From eb058eab69804cfe2e9b7dfddb2a6f2022ca3ce8 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Tue, 31 Dec 2024 19:11:04 -0500 Subject: [PATCH 5/7] fixup! Baseline formatting fixes --- src/lib_ccx/ccx_encoders_spupng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib_ccx/ccx_encoders_spupng.c b/src/lib_ccx/ccx_encoders_spupng.c index c3c19cff0..6037b53b8 100644 --- a/src/lib_ccx/ccx_encoders_spupng.c +++ b/src/lib_ccx/ccx_encoders_spupng.c @@ -705,10 +705,10 @@ uint32_t *utf8_to_utf32(char *src) // Convert big-endian and little-endian #define BigtoLittle32(A) ( \ - (((uint32_t)(A) & 0xff000000) >> 24) | \ - (((uint32_t)(A) & 0x00ff0000) >> 8) | \ - (((uint32_t)(A) & 0x0000ff00) << 8) | \ - (((uint32_t)(A) & 0x000000ff) << 24)) + (((uint32_t)(A) & 0xff000000) >> 24) | \ + (((uint32_t)(A) & 0x00ff0000) >> 8) | \ + (((uint32_t)(A) & 0x0000ff00) << 8) | \ + (((uint32_t)(A) & 0x000000ff) << 24)) // Generate PNG file from an UTF-8 string (str) // PNG file will be stored at output From 6f406ed6befa31505a81df57a3e3858349556190 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Tue, 31 Dec 2024 19:12:19 -0500 Subject: [PATCH 6/7] fixup! fixup! Baseline formatting fixes --- src/lib_ccx/ccx_encoders_spupng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_ccx/ccx_encoders_spupng.c b/src/lib_ccx/ccx_encoders_spupng.c index 6037b53b8..5c727aa7a 100644 --- a/src/lib_ccx/ccx_encoders_spupng.c +++ b/src/lib_ccx/ccx_encoders_spupng.c @@ -704,7 +704,7 @@ uint32_t *utf8_to_utf32(char *src) } // Convert big-endian and little-endian -#define BigtoLittle32(A) ( \ +#define BigtoLittle32(A) ( \ (((uint32_t)(A) & 0xff000000) >> 24) | \ (((uint32_t)(A) & 0x00ff0000) >> 8) | \ (((uint32_t)(A) & 0x0000ff00) << 8) | \ From 4a25a0420290e96fac306628deda6bb095ca5815 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Trottier Date: Tue, 31 Dec 2024 19:27:34 -0500 Subject: [PATCH 7/7] Fix rust comment formatting --- src/rust/src/decoder/encoding.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/rust/src/decoder/encoding.rs b/src/rust/src/decoder/encoding.rs index 8fabd585a..72a669572 100644 --- a/src/rust/src/decoder/encoding.rs +++ b/src/rust/src/decoder/encoding.rs @@ -1,16 +1,16 @@ -/// 256 BYTES IS ENOUGH FOR ALL THE SUPPORTED CHARACTERS IN -/// EIA-708, SO INTERNALLY WE USE THIS TABLE (FOR CONVENIENCE) -/// -/// 00-1F -> Characters that are in the G2 group in 20-3F, -/// except for 06, which is used for the closed captions -/// sign "CC" which is defined in group G3 as 00. (this -/// is by the article 33). -/// 20-7F -> Group G0 as is - corresponds to the ASCII code -/// 80-9F -> Characters that are in the G2 group in 60-7F -/// (there are several blank characters here, that's OK) -/// A0-FF -> Group G1 as is - non-English characters and symbols -/// -/// NOTE: Same as `lib_ccx/ccx_decoder_708_encoding.c` file +//! 256 BYTES IS ENOUGH FOR ALL THE SUPPORTED CHARACTERS IN +//! EIA-708, SO INTERNALLY WE USE THIS TABLE (FOR CONVENIENCE) +//! +//! 00-1F -> Characters that are in the G2 group in 20-3F, +//! except for 06, which is used for the closed captions +//! sign "CC" which is defined in group G3 as 00. (this +//! is by the article 33). +//! 20-7F -> Group G0 as is - corresponds to the ASCII code +//! 80-9F -> Characters that are in the G2 group in 60-7F +//! (there are several blank characters here, that's OK) +//! A0-FF -> Group G1 as is - non-English characters and symbols +//! +//! NOTE: Same as `lib_ccx/ccx_decoder_708_encoding.c` file #[no_mangle] pub extern "C" fn dtvcc_get_internal_from_G0(g0_char: u8) -> u8 {