From 595d0a7826e2fdb9ee859f9cde90cfef844b0342 Mon Sep 17 00:00:00 2001 From: Teddy Date: Mon, 26 Aug 2013 10:22:24 +0800 Subject: fixed a bug in server --- server/piztor/prob.py | 3 ++- server/piztor/server.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/piztor/prob.py b/server/piztor/prob.py index f18e42d..0ed328f 100644 --- a/server/piztor/prob.py +++ b/server/piztor/prob.py @@ -9,11 +9,12 @@ host = "localhost" port = 9990 def gen_auth(username, password): - length = 4 + 1 + len(username) + 1 + len(password) + length = 4 + 1 + len(username) + 1 + len(password) + 1 data = pack("!LB", length, 0x00) data += username data += "\0" data += password + data += "\0" return data def gen_update_location(token, username, lat, lng): diff --git a/server/piztor/server.py b/server/piztor/server.py index 511d51b..725fc5b 100644 --- a/server/piztor/server.py +++ b/server/piztor/server.py @@ -111,7 +111,7 @@ class UserAuthHandler(RequestHandler): raise BadReqError("Authentication: Malformed request body") username = tr_data[0:pos] - password = tr_data[pos + 1:] + password = tr_data[pos + 1:-1] logger.info("Trying to login with " \ "(username = {0}, password = {1})" \ .format(username, password)) @@ -136,7 +136,7 @@ class UserAuthHandler(RequestHandler): if uauth is None: raise DBCorruptedError() if not uauth.check_password(password): - logger.info("Incorrect password: {0}".format(username)) + logger.info("Incorrect password: {0}".format(password)) return struct.pack("!LBBL32s", UserAuthHandler \ ._user_auth_response_size, _OptCode.user_auth, -- cgit v1.2.3-70-g09d2