From b5e205b8d1ea0a62ea8847dc5510a10c65a2573e Mon Sep 17 00:00:00 2001
From: lujingxiao <lujingxiao@huawei.com>
Date: Sat, 19 Jan 2019 11:13:57 +0800
Subject: [PATCH 005/111] prjquota: fix few overlay2 quota problems

reason:fix few overlay2 quota problems

Change-Id: Id3a7915747c415d56684c291fb0498d04b762c8c
Signed-off-by: dengguangxing <dengguangxing@huawei.com>
Signed-off-by: zhangyu235 <zhangyu235@huawei.com>
Signed-off-by: lujingxiao <lujingxiao@huawei.com>
---
 components/engine/daemon/graphdriver/overlay2/overlay.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/components/engine/daemon/graphdriver/overlay2/overlay.go b/components/engine/daemon/graphdriver/overlay2/overlay.go
index 36ae182bcd..96f44ba9a1 100644
--- a/components/engine/daemon/graphdriver/overlay2/overlay.go
+++ b/components/engine/daemon/graphdriver/overlay2/overlay.go
@@ -455,6 +455,14 @@ func (d *Driver) parseStorageOpt(storageOpt map[string]string, driver *Driver) e
 			if err != nil {
 				return err
 			}
+			// deal with negative and super large number
+			if size < 0 {
+				return fmt.Errorf("Illegal storage size(%s): numerical result out of range", val)
+			}
+			// for overlay (0-1024) means no limit
+			if size < 1024 && size > 0 {
+				return fmt.Errorf("Illegal storage size:%d, 1024 at least", size)
+			}
 			driver.options.quota.Size = uint64(size)
 		default:
 			return fmt.Errorf("Unknown option %s", key)
-- 
2.17.1

