fix(gateway): enforce audited production traversal
This commit is contained in:
@@ -515,7 +515,32 @@ func apolloAnnounceProfile(policy protocol.ProviderStreamPolicy) ([]byte, error)
|
||||
}
|
||||
|
||||
func validateApolloStreamPolicy(policy protocol.ProviderStreamPolicy) error {
|
||||
if err := policy.Validate(); err != nil || !policy.AudioEnabled || (policy.Codec != "H264" && policy.Codec != "HEVC") {
|
||||
if err := policy.Validate(); err != nil || !policy.AudioEnabled || policy.BitrateKbps > 125000 ||
|
||||
(policy.Codec != "H264" && policy.Codec != "HEVC") {
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
if (policy.Codec == "H264" && (policy.ResolutionWidth > 4096 || policy.ResolutionHeight > 4096)) ||
|
||||
(policy.Codec == "HEVC" && (policy.ResolutionWidth > 8192 || policy.ResolutionHeight > 8192)) {
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateApolloProviderStreamPolicy(info ManagementInfo, policy protocol.ProviderStreamPolicy) error {
|
||||
if validateApolloStreamPolicy(policy) != nil || !info.HasServerCodecModeSupport || !info.HasMaxLumaPixelsHEVC {
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
switch policy.Codec {
|
||||
case "H264":
|
||||
if info.ServerCodecModeSupport&0x1 == 0 {
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
case "HEVC":
|
||||
luma := uint64(policy.ResolutionWidth) * uint64(policy.ResolutionHeight)
|
||||
if info.ServerCodecModeSupport&0x100 == 0 || info.MaxLumaPixelsHEVC == 0 || luma > info.MaxLumaPixelsHEVC {
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
default:
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user