fix(cloudwatch): reject invalid log event tokens (#2249)

This commit is contained in:
Langning Zhang authored and GitHub committed 2026-08-14 10:26:32 -04:00
1 parent 2d003b52f2
commit 12cf6e2fd8
2 files changed
+71 -2

No files matched your search

@@ -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);
}
/**