github-code-scanning[bot] commented on code in PR #14714:
URL: https://github.com/apache/druid/pull/14714#discussion_r1280045716


##########
extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3TaskLogs.java:
##########
@@ -87,38 +86,42 @@
   private Optional<InputStream> streamTaskFile(final long offset, String 
taskKey) throws IOException
   {
     try {
-      final ObjectMetadata objectMetadata = 
service.getObjectMetadata(config.getS3Bucket(), taskKey);
-
-      try {
-        final long start;
-        final long end = objectMetadata.getContentLength() - 1;
-
-        if (offset > 0 && offset < objectMetadata.getContentLength()) {
-          start = offset;
-        } else if (offset < 0 && (-1 * offset) < 
objectMetadata.getContentLength()) {
-          start = objectMetadata.getContentLength() + offset;
-        } else {
-          start = 0;
-        }
-
-        final GetObjectRequest request = new 
GetObjectRequest(config.getS3Bucket(), taskKey)
-            
.withMatchingETagConstraint(ensureQuotated(objectMetadata.getETag()))
-            .withRange(start, end);
-
-        return Optional.of(service.getObject(request).getObjectContent());
-      }
-      catch (AmazonServiceException e) {
-        throw new IOException(e);
-      }
+      return S3Utils.retryS3Operation(
+          () -> {
+            try {
+              final ObjectMetadata objectMetadata = 
service.getObjectMetadata(config.getS3Bucket(), taskKey);
+
+              final long start;
+              final long end = objectMetadata.getContentLength() - 1;
+
+              if (offset > 0 && offset < objectMetadata.getContentLength()) {
+                start = offset;
+              } else if (offset < 0 && (-1 * offset) < 
objectMetadata.getContentLength()) {

Review Comment:
   ## User-controlled data in arithmetic expression
   
   This arithmetic expression depends on a [user-provided value](1), 
potentially causing an underflow.
   This arithmetic expression depends on a [user-provided value](2), 
potentially causing an underflow.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5319)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to