cba790
From 13347e2450c7bfa928eb80b01850e52dfa095802 Mon Sep 17 00:00:00 2001
cba790
From: Tomas Babej <tomasbabej@gmail.com>
cba790
Date: Thu, 28 Jan 2016 15:05:01 +0100
cba790
Subject: [PATCH] resolver: Reject lines with less than two tokens
cba790
cba790
---
cba790
 dns/resolver.py | 5 ++++-
cba790
 1 file changed, 4 insertions(+), 1 deletion(-)
cba790
cba790
diff --git a/dns/resolver.py b/dns/resolver.py
cba790
index 55359fa..94360c4 100644
cba790
--- a/dns/resolver.py
cba790
+++ b/dns/resolver.py
cba790
@@ -562,8 +562,11 @@ def read_resolv_conf(self, f):
cba790
                 if len(l) == 0 or l[0] == '#' or l[0] == ';':
cba790
                     continue
cba790
                 tokens = l.split()
cba790
-                if len(tokens) == 0:
cba790
+
cba790
+                # Any line containing less than 2 tokens is malformed
cba790
+                if len(tokens) < 2:
cba790
                     continue
cba790
+
cba790
                 if tokens[0] == 'nameserver':
cba790
                     self.nameservers.append(tokens[1])
cba790
                 elif tokens[0] == 'domain':