From febc9b73df295d466816b9ae11a5299c5dd9f902 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sat, 9 Nov 2019 11:25:24 +0900 Subject: [PATCH] Fix TOCTOU issue when getting blob during removal Fixes gaul/s3proxy#318. --- .../java/org/jclouds/blobstore/config/LocalBlobStore.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java index e1dab9ff5d..9c521bebc1 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java @@ -636,14 +636,14 @@ public final class LocalBlobStore implements BlobStore { logger.debug("Container %s does not exist", containerName); throw cnfe(containerName); } + // If the blob doesn't exist, a null object is returned - if (!storageStrategy.blobExists(containerName, key)) { + Blob blob = loadBlob(containerName, key); + if (blob == null) { logger.debug("Item %s does not exist in container %s", key, containerName); return null; } - Blob blob = loadBlob(containerName, key); - if (options != null) { String eTag = blob.getMetadata().getETag(); if (eTag != null) {