summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorBlair Zajac <blair@orcaware.com>2013-03-10 19:45:42 -0700
committerBlair Zajac <blair@orcaware.com>2013-03-10 19:45:42 -0700
commit335aded5400d6eb019cd0ee68dac2b643398240c (patch)
tree2b1037305526b0f36025c042768889d3b3833fe0 /cloudinit/util.py
parenteab08ade4bc56219e98bcc1d5568b75b6f4bb6ea (diff)
downloadvyos-cloud-init-335aded5400d6eb019cd0ee68dac2b643398240c.tar.gz
vyos-cloud-init-335aded5400d6eb019cd0ee68dac2b643398240c.zip
util.parse_mount_info(): handle short lines.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py11
1 files changed, 11 insertions, 0 deletions
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]