Browse code

Merge pull request #41830 from ob/master

Fix an off-by-one bug

Akihiro Suda authored on 2020/12/22 13:43:56
Showing 1 changed files
... ...
@@ -573,14 +573,14 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e
573 573
 	// the page size. The mount syscall fails if the mount data cannot
574 574
 	// fit within a page and relative links make the mount data much
575 575
 	// smaller at the expense of requiring a fork exec to chroot.
576
-	if len(mountData) > pageSize {
576
+	if len(mountData) > pageSize-1 {
577 577
 		if readonly {
578 578
 			opts = indexOff + "lowerdir=" + path.Join(id, diffDirName) + ":" + string(lowers)
579 579
 		} else {
580 580
 			opts = indexOff + "lowerdir=" + string(lowers) + ",upperdir=" + path.Join(id, diffDirName) + ",workdir=" + path.Join(id, workDirName)
581 581
 		}
582 582
 		mountData = label.FormatMountLabel(opts, mountLabel)
583
-		if len(mountData) > pageSize {
583
+		if len(mountData) > pageSize-1 {
584 584
 			return nil, fmt.Errorf("cannot mount layer, mount label too large %d", len(mountData))
585 585
 		}
586 586