mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cloudwatch): reject invalid log event tokens (#2249)
This commit is contained in:
1 parent
2d003b52f2
commit
12cf6e2fd8
2 files changed
+71
-2
No files matched your search
+13
-2
@@ -387,6 +387,8 @@ public class CloudWatchLogsService {
|
||||
int end = parseTokenIndex(nextToken, 2);
|
||||
pageEnd = Math.min(end, total);
|
||||
pageStart = Math.max(pageEnd - maxEvents, 0);
|
||||
} else if (nextToken != null) {
|
||||
throw invalidNextToken();
|
||||
} else if (!startFromHead) {
|
||||
pageEnd = total;
|
||||
pageStart = Math.max(total - maxEvents, 0);
|
||||
@@ -400,11 +402,20 @@ public class CloudWatchLogsService {
|
||||
}
|
||||
|
||||
private int parseTokenIndex(String token, int prefixLen) {
|
||||
int index;
|
||||
try {
|
||||
return Integer.parseInt(token.substring(prefixLen));
|
||||
index = Integer.parseInt(token.substring(prefixLen));
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
throw invalidNextToken();
|
||||
}
|
||||
if (index < 0) {
|
||||
throw invalidNextToken();
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
private AwsException invalidNextToken() {
|
||||
return new AwsException("InvalidParameterException", "The specified nextToken is invalid.", 400);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user