[lxc-devel] [lxc/master] utils: handle > 2^31 in lxc_unstack_mountpoint()
brauner on Github
lxc-bot at linuxcontainers.org
Wed May 10 15:48:17 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 412 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170510/42944d58/attachment.bin>
-------------- next part --------------
From 640bfdfed1ef117f01dedb100afca9281c4467df Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 10 May 2017 16:56:37 +0200
Subject: [PATCH] utils: handle > 2^31 in lxc_unstack_mountpoint()
I mean.. really? But better safe than sorry.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/utils.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index ae23d40..a14e1ea 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -2208,7 +2208,7 @@ int lxc_prepare_loop_dev(const char *source, char *loop_dev, int flags)
int lxc_unstack_mountpoint(const char *path, bool lazy)
{
int ret;
- int umounts = 0;
+ long int umounts = 0;
pop_stack:
ret = umount2(path, lazy ? MNT_DETACH : 0);
@@ -2221,12 +2221,17 @@ int lxc_unstack_mountpoint(const char *path, bool lazy)
if (errno != EINVAL)
return -errno;
} else {
+ /* Just stop counting when this happens. That'd just be so
+ * stupid that we won't even bother trying to report back the
+ * correct value anymore.
+ */
+ if ((long) (int) umounts == umounts)
+ umounts++;
/* We succeeded in umounting. Make sure that there's no other
* mountpoint stacked underneath.
*/
- umounts++;
goto pop_stack;
}
- return umounts;
+ return (int)umounts;
}
More information about the lxc-devel
mailing list