From 9b59418edf754f2f202572521b819871f8da84c8 Mon Sep 17 00:00:00 2001 From: BigUstad Date: Tue, 3 Dec 2019 13:27:13 -0800 Subject: [PATCH] Validate bucket name, object name. Fixes #819 --- api/src/main/java/io/minio/MinioClient.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/src/main/java/io/minio/MinioClient.java b/api/src/main/java/io/minio/MinioClient.java index 73ac0287e..542f11b48 100755 --- a/api/src/main/java/io/minio/MinioClient.java +++ b/api/src/main/java/io/minio/MinioClient.java @@ -1547,8 +1547,24 @@ public ObjectStat statObject(String bucketName, String objectName, ServerSideEnc headers = sse.headers(); } + checkBucketName(bucketName); + String errorMessage = ""; + if ( objectName == null ) { + errorMessage += " Object name cannot be null."; + } else if ( objectName.equals("") ) { + errorMessage += " Object name cannot be empty."; + } + if ( !errorMessage.equals("") ) { + throw new InvalidArgumentException("Invalid Stat Object Argument(s)." + errorMessage); + } HttpResponse response = executeHead(bucketName, objectName, headers); ResponseHeader header = response.header(); + if ( header.contentLength() == 0 + && header.contentType() == null + && header.statusCode() == null ) { + throw new InvalidArgumentException("Invalid Stat Object Arguments."); + } + Map> httpHeaders = response.httpHeaders(); ObjectStat objectStat = new ObjectStat(bucketName, objectName, header, httpHeaders); return objectStat;