aboutsummaryrefslogtreecommitdiff
path: root/video_player
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-11 12:41:16 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-11 12:41:37 +0100
commitfc27e590c39e3b309683e275541fd9b3164985dc (patch)
tree4eeb9272ffd2f469f0ce2c857c2f1ec303df3da4 /video_player
parentd92f6d7725720e3facf90b0fdefc1ef4eb1c2227 (diff)
Fix youtube streaming for really long videos
I dedicate this one to rat
Diffstat (limited to 'video_player')
-rw-r--r--video_player/src/main.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/video_player/src/main.cpp b/video_player/src/main.cpp
index 4ec9278..e166e85 100644
--- a/video_player/src/main.cpp
+++ b/video_player/src/main.cpp
@@ -449,25 +449,33 @@ static int64_t size_fn(void *cookie) {
if(res == 0) {
size_t header_start = str_find_case_insensitive(buffer, 0, "200 OK", 6);
- if(header_start == std::string::npos)
+ if(header_start == std::string::npos) {
+ res = MPV_ERROR_UNSUPPORTED;
goto end;
+ }
header_start += 6;
size_t content_length_index = str_find_case_insensitive(buffer, header_start, "content-length:", 15);
- if(content_length_index == std::string::npos)
+ if(content_length_index == std::string::npos) {
+ res = MPV_ERROR_UNSUPPORTED;
goto end;
+ }
content_length_index += 15;
size_t content_length_end = buffer.find('\r', content_length_index);
- if(content_length_end == std::string::npos)
+ if(content_length_end == std::string::npos) {
+ res = MPV_ERROR_UNSUPPORTED;
goto end;
+ }
buffer[content_length_end] = '\0';
errno = 0;
char *endptr;
int64_t content_length = strtoll(&buffer[content_length_index], &endptr, 10);
- if(endptr == &buffer[content_length_index] || errno != 0)
+ if(endptr == &buffer[content_length_index] || errno != 0) {
+ res = MPV_ERROR_UNSUPPORTED;
goto end;
+ }
res = content_length;
}