fix(terabox): panic due to slice out of range #7499
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修复问题
#7487 中第
1
个问题:如果Terobox
的Cookie
失效或填写错误,会在driver Init
阶段panic
问题原因
https://github.com/AlistGo/alist/blob/0a46979c519885465e586da009b70422382c84ac/drivers/terabox/util.go#L90C3-L90C61
Terobox Init
进行登录时,如果当前ip
与注册时的区域不符时,接口会返回errno=6
然后进入这段逻辑,并根据header
中返回的url prefix
设置正确的url
prefix
后重新请求时,如果Cookie
不合法,也会返回errno=6
,导致再次进入到这段逻辑中,由于这时header
中没有Url-Domain-Prefix
了,导致访问nil
的切片造成panic
修复方案
增加非空判断,如果
Cookie
不合法则会抛出错误