Index: /trunk/src/VBox/Storage/VDI.cpp
===================================================================
--- /trunk/src/VBox/Storage/VDI.cpp	(revision 64692)
+++ /trunk/src/VBox/Storage/VDI.cpp	(revision 64693)
@@ -2462,4 +2462,11 @@
     PVDIIMAGEDESC pImage = (PVDIIMAGEDESC)pBackendData;
     int rc = VINF_SUCCESS;
+
+    /* Check size. Maximum 4PB-3M. No tricks with adjusting the 1M block size
+     * so far, which would extend the size. */
+    if (   !cbSize
+        || cbSize >= _1P * 4 - _1M * 3
+        || cbSize < VDI_IMAGE_DEFAULT_BLOCK_SIZE)
+        return VERR_VD_INVALID_SIZE;
 
     /*
