

def post(self):
    self.response.headers.add_header('Access-Control-Allow-Origin', '*')
    STR_VERSERVER = '01060000'
    INT_VERCLIENT = 17170432
    STR_VERCLIENT = '1.6'
    if (not os.environ.has_key('HTTPS')):
        self.resp_simple(0, 'HTTPS environment variable not found')
        return
    if (not os.environ.has_key('CURRENT_VERSION_ID')):
        self.resp_simple(0, 'CURRENT_VERSION_ID environment variable not found')
        return
    HTTPS = os.environ.get('HTTPS', 'off')
    CURRENT_VERSION_ID = os.environ.get('CURRENT_VERSION_ID', STR_VERSERVER)
    if (HTTPS.__str__() != 'on'):
        self.resp_simple(0, 'Secure socket required.')
        return
    minlen = (4 + 4)
    self.response.headers['Content-Type'] = 'application/octet-stream'
    data = self.request.body
    size = str.__len__(data)
    if (size < postKeyNodes):
        self.resp_simple(0, 'Request was formatted incorrectly.')
        return
    server = int(CURRENT_VERSION_ID[0:8], 16)
    client = struct.unpack('!i', data[0:4])[0]
    usrid = struct.unpack('!i', data[4:8])[0]
    data = data[8:]
    expectedsize = (4 + 4)
    postKeyNodes = False
    if (size > expectedsize):
        usridpost = struct.unpack('!i', data[0:4])[0]
        sizeData = struct.unpack('!i', data[4:8])[0]
        key_node = struct.unpack((str(sizeData) + 's'), data[8:(8 + sizeData)])[0]
        postKeyNodes = True
    if (client < INT_VERCLIENT):
        self.resp_simple(0, ('Client version mismatch; %s required.  Download latest client release first.' % STR_VERCLIENT))
        return
    query = member.Member.all()
    query.filter('usr_id =', usrid)
    num = query.count()
    if (num == 1):
        mem = query.get()
        if postKeyNodes:
            query = member.Member.all()
            query.filter('usr_id =', usridpost)
            num = query.count()
            if (num == 1):
                mem_other = query.get()
                mem_other.key_node = key_node
                mem_other.put()
                key = mem_other.key()
                if (not key.has_id_or_name()):
                    self.resp_simple(0, 'Unable to update user.')
                    return
            else:
                self.resp_simple(0, (' user %i does not exist for update' % usridpost))
                return
        self.response.out.write(('%s' % struct.pack('!i', server)))
        mem = query.get()
        if (mem.key_node != None):
            self.response.out.write(('%s' % struct.pack('!i', num)))
            length = str.__len__(mem.key_node)
            self.response.out.write(('%s%s' % (struct.pack('!i', length), mem.key_node)))
        else:
            self.response.out.write(('%s' % struct.pack('!i', 0)))
    else:
        self.resp_simple(0, (' user %i does not exist' % usrid))
        return

dataset/ETHPy150Open SafeSlingerProject/SafeSlinger-AppEngine/safeslinger-exchange/python/syncKeyNodes.py SyncKeyNodes.post/VarMisuse@180/293 `minlen`->`postKeyNodes`