From 19c9eada9d44aa1e4ffaa36193de77c86ef3e1c1 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Wed, 28 Jan 2026 17:32:10 +0100 Subject: [PATCH] check first the filesize before opening a Reader to the config file --- .../org/cryptomator/launcher/AdminPropertiesSetter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java index 5c1c2ed60..c32687226 100644 --- a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java +++ b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java @@ -92,11 +92,13 @@ class AdminPropertiesSetter { //visible for testing static Properties loadAdminProperties(Path adminPropertiesPath) { var adminProps = new Properties(); - try (var reader = Files.newBufferedReader(adminPropertiesPath, StandardCharsets.UTF_8)) { - if(Files.size(adminPropertiesPath) > MAX_CONFIG_SIZE_BYTES) { + try { + if (Files.size(adminPropertiesPath) > MAX_CONFIG_SIZE_BYTES) { throw new IOException("Config file %s exceeds maximum size of %d".formatted(adminPropertiesPath, MAX_CONFIG_SIZE_BYTES)); } - adminProps.load(reader); + try (var reader = Files.newBufferedReader(adminPropertiesPath, StandardCharsets.UTF_8)) { + adminProps.load(reader); + } } catch (NoSuchFileException _) { //NO-OP LOG.debug("No admin properties found at {}.", adminPropertiesPath);