def read_cstr(file):
    """read zero terminated c string from file"""
    output = ''
    while True:
        char = file.read(1)
        if len(char) == 0:
            raise RuntimeError('EOF while reading cstr')
        char = chr(bytes(char)[0])
        if char == '\x00':
            break
        output += char
    return output
