def read_null_terminated_string(f):
    """
    Read a null terminated string from a file-like object.

    :param f: file-like object
    :rtype: bytearray
    """
    x = bytearray()
    while True:
        z = f.read(1)
        if ord(z) == 0:
            return x
        else:
            x.append(ord(z))