[MM-38321] Fix possible panics during license validation (#18333)

* Fix possible panics during license validation

* Return error if non 2xx code is returned by trial request server
Этот коммит содержится в:
Claudio Costa
2021-09-02 18:57:18 +02:00
коммит произвёл GitHub
родитель 21a53320d3
Коммит 236d46ecc6
3 изменённых файлов: 61 добавлений и 11 удалений

Просмотреть файл

@@ -71,16 +71,16 @@ func (l *LicenseValidatorImpl) ValidateLicense(signed []byte) (bool, string) {
return false, ""
}
// remove null terminator
for len(decoded) > 0 && decoded[len(decoded)-1] == byte(0) {
decoded = decoded[:len(decoded)-1]
}
if len(decoded) <= 256 {
mlog.Error("Signed license not long enough")
return false, ""
}
// remove null terminator
for decoded[len(decoded)-1] == byte(0) {
decoded = decoded[:len(decoded)-1]
}
plaintext := decoded[:len(decoded)-256]
signature := decoded[len(decoded)-256:]