From 335aded5400d6eb019cd0ee68dac2b643398240c Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Sun, 10 Mar 2013 19:45:42 -0700 Subject: util.parse_mount_info(): handle short lines. --- cloudinit/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cloudinit/util.py b/cloudinit/util.py index 0c30f771..a1f6e004 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1588,6 +1588,17 @@ def parse_mount_info(path, mountinfo_lines, log=LOG): for i, line in enumerate(mountinfo_lines): parts = line.split() + # Completely fail if there is anything in any line that is + # unexpected, as continuing to parse past a bad line could + # cause an incorrect result to be returned, so it's better + # return nothing than an incorrect result. + + # The minimum number of elements in a valid line is 10. + if len(parts) < 10: + log.debug("Line %d has two few columns (%d): %s", + i + 1, len(parts), line) + return None + mount_point = parts[4] mount_point_elements = [e for e in mount_point.split('/') if e] -- cgit v1.2.3