def extend(value, length):
    """ Extends a string value to an exact size """
    remainder = length - len(value)
    value += b''.join([b'\x00' for _ in range(remainder)])
    value = value[:length]
    return value