File: 0063-stream_extractor-set-correct-offset-on-read-failure.patch

package info (click to toggle)
vlc 3.0.21-10
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 212,728 kB
  • sloc: ansic: 441,379; cpp: 110,628; objc: 36,394; sh: 6,947; makefile: 6,592; javascript: 4,902; xml: 1,611; asm: 1,355; yacc: 640; python: 555; lex: 88; perl: 77; sed: 16
file content (51 lines) | stat: -rw-r--r-- 1,741 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From: Francois Cartegnie <fcvlcdev@free.fr>
Date: Thu, 1 Jun 2023 17:44:52 +0700
Subject: stream_extractor: set correct offset on read failure

(cherry picked from commit 9f160402e3ea835f1d242e8ca5af89c57a3a2583)
---
 modules/stream_extractor/archive.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/stream_extractor/archive.c b/modules/stream_extractor/archive.c
index c69c9f2..446d711 100644
--- a/modules/stream_extractor/archive.c
+++ b/modules/stream_extractor/archive.c
@@ -609,16 +609,16 @@ eof:
     return 0;
 }
 
-static int archive_skip_decompressed( stream_extractor_t* p_extractor, uint64_t i_skip )
+static int archive_skip_decompressed( stream_extractor_t* p_extractor, uint64_t *pi_skip )
 {
-    while( i_skip )
+    while( *pi_skip )
     {
-        ssize_t i_read = Read( p_extractor, NULL, i_skip );
+        ssize_t i_read = Read( p_extractor, NULL, *pi_skip );
 
         if( i_read < 1 )
             return VLC_EGENERIC;
 
-        i_skip -= i_read;
+        *pi_skip -= i_read;
     }
 
     return VLC_SUCCESS;
@@ -663,9 +663,13 @@ static int Seek( stream_extractor_t* p_extractor, uint64_t i_req )
             i_skip = i_req;
             i_offset = 0;
         }
-
-        if( archive_skip_decompressed( p_extractor, i_skip ) )
-            msg_Dbg( p_extractor, "failed to skip to seek position" );
+        if( archive_skip_decompressed( p_extractor, &i_skip ) )
+        {
+            msg_Warn( p_extractor, "failed to skip to seek position %" PRIu64 "/%" PRId64,
+                      i_req, archive_entry_size( p_sys->p_entry ) );
+            p_sys->i_offset += i_skip;
+            return VLC_EGENERIC;
+        }
     }
 
     p_sys->i_offset = i_req;