mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-28 21:14:03 +08:00
test: address AMF depth review feedback
This commit is contained in:
@@ -93,6 +93,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
explicit DepthGuard(AMFDecoder &decoder);
|
explicit DepthGuard(AMFDecoder &decoder);
|
||||||
~DepthGuard();
|
~DepthGuard();
|
||||||
|
DepthGuard(const DepthGuard &) = delete;
|
||||||
|
DepthGuard(DepthGuard &&) = delete;
|
||||||
|
DepthGuard &operator=(const DepthGuard &) = delete;
|
||||||
|
DepthGuard &operator=(DepthGuard &&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AMFDecoder &_decoder;
|
AMFDecoder &_decoder;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
* may be found in the AUTHORS file in the root of the source tree.
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -34,17 +34,24 @@ int main() {
|
|||||||
{
|
{
|
||||||
BufferLikeString input(make_nested_object(64));
|
BufferLikeString input(make_nested_object(64));
|
||||||
AMFDecoder decoder(input, 0);
|
AMFDecoder decoder(input, 0);
|
||||||
assert(decoder.load<AMFValue>().type() == AMF_OBJECT);
|
if (decoder.load<AMFValue>().type() != AMF_OBJECT) {
|
||||||
|
cerr << "AMF object at the nesting limit was not decoded" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
BufferLikeString input(make_nested_object(65));
|
BufferLikeString input(make_nested_object(65));
|
||||||
AMFDecoder decoder(input, 0);
|
AMFDecoder decoder(input, 0);
|
||||||
|
bool depth_rejected = false;
|
||||||
try {
|
try {
|
||||||
decoder.load<AMFValue>();
|
decoder.load<AMFValue>();
|
||||||
assert(false);
|
|
||||||
} catch (const runtime_error &ex) {
|
} catch (const runtime_error &ex) {
|
||||||
assert(string(ex.what()) == "Maximum AMF nesting depth exceeded");
|
depth_rejected = string(ex.what()) == "Maximum AMF nesting depth exceeded";
|
||||||
|
}
|
||||||
|
if (!depth_rejected) {
|
||||||
|
cerr << "AMF object beyond the nesting limit was not rejected" << endl;
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user