Changeset

2252:98a2bc275e0e

util.sasl.plain: Fail gracefully on empty <auth/> tag
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Nov 2009 15:12:43 +0000
parents 2251:18079ede5b62
children 2253:a3537266a916 2254:f966c8699f5b
files util/sasl/plain.lua
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/util/sasl/plain.lua	Sat Nov 28 15:12:07 2009 +0000
+++ b/util/sasl/plain.lua	Sat Nov 28 15:12:43 2009 +0000
@@ -21,10 +21,14 @@
 --SASL PLAIN according to RFC 4616
 local function plain(self, message)
 	local response = message
-	local authorization = s_match(response, "([^%z]+)")
-	local authentication = s_match(response, "%z([^%z]+)%z")
-	local password = s_match(response, "%z[^%z]+%z([^%z]+)")
-
+	
+	local authorization, authentication, password;
+	if response then
+		authorization = s_match(response, "([^%z]+)")
+		authentication = s_match(response, "%z([^%z]+)%z")
+		password = s_match(response, "%z[^%z]+%z([^%z]+)")
+	end
+	
 	if authentication == nil or password == nil then
 		return "failure", "malformed-request";
 	end
@@ -63,4 +67,4 @@
 	registerMechanism("PLAIN", {"plain", "plain_test"}, plain);
 end
 
-return _M;
\ No newline at end of file
+return _M;