def read_string(fd, loc=None):
    """
    Read a null-terminated string.
    The file descriptor is set to one past the null.

    :param fd: file handle opened in binary mode
    :return: the decoded string
    """
    if loc is not None:
        fd.seek(loc)
    b = b""
    while True:
        bb = fd.read(1)
        if bb == b"\x00":
            break
        b += bb
    return b.decode("utf-8")