Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #54385 to 23.8: Check for overflow before addition in analysisOfVariance function #54418

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/AggregateFunctions/Moments.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ struct AnalysisOfVarianceMoments

void add(T value, size_t group)
{
if (group == std::numeric_limits<size_t>::max())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Too many groups for analysis of variance (should be no more than {}, got {})",
MAX_GROUPS_NUMBER, group);

resizeIfNeeded(group + 1);
xs1[group] += value;
xs2[group] += value * value;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT analysisOfVariance(1, 18446744073709551615); -- { serverError BAD_ARGUMENTS }