diff options
author | Daniel Watkins <daniel.watkins@canonical.com> | 2015-10-09 14:01:11 +0100 |
---|---|---|
committer | Daniel Watkins <daniel.watkins@canonical.com> | 2015-10-09 14:01:11 +0100 |
commit | 20dc4190e27c7778cfa6c2943961f2ad27e14b48 (patch) | |
tree | 40cc168db55c00dd58473ce2f5aeeb8322954a52 /cloudinit | |
parent | 41900b72f31a1bd0eebe2f58a8598bfab25f0003 (diff) | |
download | vyos-cloud-init-20dc4190e27c7778cfa6c2943961f2ad27e14b48.tar.gz vyos-cloud-init-20dc4190e27c7778cfa6c2943961f2ad27e14b48.zip |
Handle colons in packed strings in WALinuxAgentShim.find_endpoint.
This fixes bug 1488896.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/sources/helpers/azure.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py index 33003da0..21b4cd21 100644 --- a/cloudinit/sources/helpers/azure.py +++ b/cloudinit/sources/helpers/azure.py @@ -225,16 +225,18 @@ class WALinuxAgentShim(object): value = line.strip(' ').split(' ', 2)[-1].strip(';\n"') if value is None: raise Exception('No endpoint found in DHCP config.') - if ':' in value: + unescaped_value = value.replace('\\', '') + if len(unescaped_value) > 4: hex_string = '' - for hex_pair in value.split(':'): + for hex_pair in unescaped_value.split(':'): if len(hex_pair) == 1: hex_pair = '0' + hex_pair hex_string += hex_pair - value = struct.pack('>L', int(hex_string.replace(':', ''), 16)) + packed_bytes = struct.pack( + '>L', int(hex_string.replace(':', ''), 16)) else: - value = value.replace('\\', '').encode('utf-8') - endpoint_ip_address = socket.inet_ntoa(value) + packed_bytes = unescaped_value.encode('utf-8') + endpoint_ip_address = socket.inet_ntoa(packed_bytes) LOG.debug('Azure endpoint found at %s', endpoint_ip_address) return endpoint_ip_address |