src/java.base/unix/classes/sun/nio/fs/UnixFileStore.java
changeset 58897 76638c631869
parent 50817 fa1e04811ff6
--- a/src/java.base/unix/classes/sun/nio/fs/UnixFileStore.java	Fri Nov 01 12:57:01 2019 +0000
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileStore.java	Fri Nov 01 13:16:50 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -118,13 +118,31 @@
     @Override
     public long getTotalSpace() throws IOException {
         UnixFileStoreAttributes attrs = readAttributes();
-        return attrs.blockSize() * attrs.totalBlocks();
+        try {
+            return Math.multiplyExact(attrs.blockSize(), attrs.totalBlocks());
+        } catch (ArithmeticException ignore) {
+            return Long.MAX_VALUE;
+        }
     }
 
     @Override
     public long getUsableSpace() throws IOException {
-       UnixFileStoreAttributes attrs = readAttributes();
-       return attrs.blockSize() * attrs.availableBlocks();
+        UnixFileStoreAttributes attrs = readAttributes();
+        try {
+            return Math.multiplyExact(attrs.blockSize(), attrs.availableBlocks());
+        } catch (ArithmeticException ignore) {
+            return Long.MAX_VALUE;
+        }
+    }
+
+    @Override
+    public long getUnallocatedSpace() throws IOException {
+        UnixFileStoreAttributes attrs = readAttributes();
+        try {
+            return Math.multiplyExact(attrs.blockSize(), attrs.freeBlocks());
+        } catch (ArithmeticException ignore) {
+            return Long.MAX_VALUE;
+        }
     }
 
     @Override
@@ -134,12 +152,6 @@
     }
 
     @Override
-    public long getUnallocatedSpace() throws IOException {
-        UnixFileStoreAttributes attrs = readAttributes();
-        return attrs.blockSize() * attrs.freeBlocks();
-    }
-
-    @Override
     public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> view)
     {
         if (view == null)