Changeset e1ae8b3 for remit


Ignore:
Timestamp:
Apr 20, 2010, 7:36:22 PM (15 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
fe43b8a
Parents:
734ef4f
git-author:
Alex Dehnert <adehnert@…> (04/20/10 19:36:22)
git-committer:
Alex Dehnert <adehnert@…> (04/20/10 19:36:22)
Message:

Do argument-length checking in SocketAuth?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • remit/util/SocketAuth.py

    r734ef4f re1ae8b3  
    2020    """
    2121    def authenticate(self, username, password, ):
    22         (result,) = query("AUTHENTICATE", username, password, )
     22        (result,) = query(1, "AUTHENTICATE", username, password, )
    2323        print result
    2424        if result == 'true':
     
    3939                # Should I do more error-checking? Yes.
    4040                # Do I care? No.
    41                 (first, last, email,) = query('FINGER', username)
     41                (first, last, email,) = query(3, 'FINGER', username)
    4242                user.first_name = first
    4343                user.last_name = last
     
    5353            return None
    5454
    55 
    56 def query(*args):
     55def query(length, *args):
    5756    conn = socket.socket(socket.AF_UNIX)
    5857    conn.connect(settings.AUTH_SOCK)
    5958    conn.send('\n'.join(args))
    6059    conn.shutdown(socket.SHUT_WR)
    61     result = conn.makefile().read().strip().split('\n')
     60    result = conn.makefile().read().split('\n')
     61    if(len(result)==length+1 and result[-1] == ''):
     62        result = result[:-1]
     63    if len(result) != length:
     64        raise ValueError("Got return value of length %d to query '%s'; needed length %d" % (len(result), args[0], length, ))
    6265    conn.close()
    6366    return result
Note: See TracChangeset for help on using the changeset viewer.