File tree Expand file tree Collapse file tree 7 files changed +66
-8
lines changed Expand file tree Collapse file tree 7 files changed +66
-8
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ service::AwaitableResolver Result<learn::Episode>::convert(service::AwaitableSca
50
50
return ModifiedResult<learn::Episode>::resolve (std::move (result), std::move (params),
51
51
[](learn::Episode value, const ResolverParams&)
52
52
{
53
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesEpisode[static_cast <std::size_t >(value)] } } } };
53
+ const size_t idx = static_cast <size_t >(value);
54
+
55
+ if (idx >= s_namesEpisode.size ())
56
+ {
57
+ throw service::schema_exception { { R"ex( Enum value out of range for Episode)ex" } };
58
+ }
59
+
60
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesEpisode[idx] } } } };
54
61
});
55
62
}
56
63
Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ service::AwaitableResolver Result<proxy::OperationType>::convert(service::Awaita
50
50
return ModifiedResult<proxy::OperationType>::resolve (std::move (result), std::move (params),
51
51
[](proxy::OperationType value, const ResolverParams&)
52
52
{
53
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesOperationType[static_cast <std::size_t >(value)] } } } };
53
+ const size_t idx = static_cast <size_t >(value);
54
+
55
+ if (idx >= s_namesOperationType.size ())
56
+ {
57
+ throw service::schema_exception { { R"ex( Enum value out of range for OperationType)ex" } };
58
+ }
59
+
60
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesOperationType[idx] } } } };
54
61
});
55
62
}
56
63
Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ service::AwaitableResolver Result<today::TaskState>::convert(service::AwaitableS
50
50
return ModifiedResult<today::TaskState>::resolve (std::move (result), std::move (params),
51
51
[](today::TaskState value, const ResolverParams&)
52
52
{
53
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[static_cast <std::size_t >(value)] } } } };
53
+ const size_t idx = static_cast <size_t >(value);
54
+
55
+ if (idx >= s_namesTaskState.size ())
56
+ {
57
+ throw service::schema_exception { { R"ex( Enum value out of range for TaskState)ex" } };
58
+ }
59
+
60
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[idx] } } } };
54
61
});
55
62
}
56
63
Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ service::AwaitableResolver Result<today::TaskState>::convert(service::AwaitableS
50
50
return ModifiedResult<today::TaskState>::resolve (std::move (result), std::move (params),
51
51
[](today::TaskState value, const ResolverParams&)
52
52
{
53
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[static_cast <std::size_t >(value)] } } } };
53
+ const size_t idx = static_cast <size_t >(value);
54
+
55
+ if (idx >= s_namesTaskState.size ())
56
+ {
57
+ throw service::schema_exception { { R"ex( Enum value out of range for TaskState)ex" } };
58
+ }
59
+
60
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTaskState[idx] } } } };
54
61
});
55
62
}
56
63
Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ service::AwaitableResolver Result<validation::DogCommand>::convert(service::Awai
50
50
return ModifiedResult<validation::DogCommand>::resolve (std::move (result), std::move (params),
51
51
[](validation::DogCommand value, const ResolverParams&)
52
52
{
53
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDogCommand[static_cast <std::size_t >(value)] } } } };
53
+ const size_t idx = static_cast <size_t >(value);
54
+
55
+ if (idx >= s_namesDogCommand.size ())
56
+ {
57
+ throw service::schema_exception { { R"ex( Enum value out of range for DogCommand)ex" } };
58
+ }
59
+
60
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDogCommand[idx] } } } };
54
61
});
55
62
}
56
63
@@ -102,7 +109,14 @@ service::AwaitableResolver Result<validation::CatCommand>::convert(service::Awai
102
109
return ModifiedResult<validation::CatCommand>::resolve (std::move (result), std::move (params),
103
110
[](validation::CatCommand value, const ResolverParams&)
104
111
{
105
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesCatCommand[static_cast <std::size_t >(value)] } } } };
112
+ const size_t idx = static_cast <size_t >(value);
113
+
114
+ if (idx >= s_namesCatCommand.size ())
115
+ {
116
+ throw service::schema_exception { { R"ex( Enum value out of range for CatCommand)ex" } };
117
+ }
118
+
119
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesCatCommand[idx] } } } };
106
120
});
107
121
}
108
122
Original file line number Diff line number Diff line change @@ -1692,12 +1692,14 @@ service::AwaitableResolver Result<)cpp"
1692
1692
<< R"cpp( ::)cpp" << enumType.cppType << R"cpp( value, const ResolverParams&)
1693
1693
{
1694
1694
const size_t idx = static_cast<size_t>(value);
1695
+
1695
1696
if (idx >= s_names)cpp"
1696
1697
<< enumType.cppType << R"cpp( .size())
1697
1698
{
1698
1699
throw service::schema_exception { { R"ex(Enum value out of range for )cpp"
1699
1700
<< enumType.type << R"cpp( )ex" } };
1700
1701
}
1702
+
1701
1703
return ResolverResult { { response::ValueToken::EnumValue { std::string { s_names)cpp"
1702
1704
<< enumType.cppType << R"cpp( [idx] } } } };
1703
1705
});
Original file line number Diff line number Diff line change @@ -50,7 +50,14 @@ service::AwaitableResolver Result<introspection::TypeKind>::convert(service::Awa
50
50
return ModifiedResult<introspection::TypeKind>::resolve (std::move (result), std::move (params),
51
51
[](introspection::TypeKind value, const ResolverParams&)
52
52
{
53
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTypeKind[static_cast <std::size_t >(value)] } } } };
53
+ const size_t idx = static_cast <size_t >(value);
54
+
55
+ if (idx >= s_namesTypeKind.size ())
56
+ {
57
+ throw service::schema_exception { { R"ex( Enum value out of range for __TypeKind)ex" } };
58
+ }
59
+
60
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesTypeKind[idx] } } } };
54
61
});
55
62
}
56
63
@@ -102,7 +109,14 @@ service::AwaitableResolver Result<introspection::DirectiveLocation>::convert(ser
102
109
return ModifiedResult<introspection::DirectiveLocation>::resolve (std::move (result), std::move (params),
103
110
[](introspection::DirectiveLocation value, const ResolverParams&)
104
111
{
105
- return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDirectiveLocation[static_cast <std::size_t >(value)] } } } };
112
+ const size_t idx = static_cast <size_t >(value);
113
+
114
+ if (idx >= s_namesDirectiveLocation.size ())
115
+ {
116
+ throw service::schema_exception { { R"ex( Enum value out of range for __DirectiveLocation)ex" } };
117
+ }
118
+
119
+ return ResolverResult { { response::ValueToken::EnumValue { std::string { s_namesDirectiveLocation[idx] } } } };
106
120
});
107
121
}
108
122
You can’t perform that action at this time.
0 commit comments