From f47487c219978cd9d9db34f7b1669e5e44051af1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 24 Feb 2024 22:38:22 +0100 Subject: [PATCH] libssh/libssh2: return error on too big range If trying to get the range 0 - 2^63 and the remote file is 2^63 bytes or larger. Fixes #12983 Closes #12984 --- lib/vssh/libssh.c | 2 ++ lib/vssh/libssh2.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index c6dc63ae66..02148d0c18 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -1665,6 +1665,8 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) size = 0; } else { + if((to - from) == CURL_OFF_T_MAX) + return CURLE_RANGE_ERROR; size = to - from + 1; } diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index e9dfef950d..3a661f81eb 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -2544,6 +2544,8 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) size = 0; } else { + if((to - from) == CURL_OFF_T_MAX) + return CURLE_RANGE_ERROR; size = to - from + 1; }