def get_string(stream):
    'Use this to grab a "string" from a bytearray() stream.\n\n    C\'s printf() prints until it encounters a null byte (b\'\x00\'). This function behaves the same.\n\n    Positional arguments:\n    stream -- bytearray stream of data.\n\n    Returns:\n    bytes() instance of any characters from the start of the stream until before the first null byte.\n    '
    ba = bytearray()
    for c in stream:
        if not c:
            break
        ba.append(c)
    return bytes(ba)
