On Mon, Oct 03, 2011 at 09:56:47AM -0500, Anthony Liguori wrote: > On 10/03/2011 09:18 AM, Michael S. Tsirkin wrote: > >>skip_indefinite: > >> while tag != CANARY: > >> if tag == INT: > >> visit_type_int(v, NULL, NULL, errp); > >> elif tag == STRING: > >> visit_type_str(v, NULL, NULL, errp); > >> elif tag == INDEFINITE: > >> visit_start_struct(v, NULL, NULL, errp); > >> skip_indefinite(v, errp); > >> visit_end_struct(v, NULL, NULL, errp); > >> > >>end_struct: > >> v->skip = true; > >> skip_indefinite(v, errp); > >> v->skip = false; > >> > >>Regards, > >> > >>Anthony Liguori > > > >This implementation is recursive, which has the problem > >of wasting unlimited resources to skip bad input. > >And we really do not need to look at tag at all. Just > >the length. > > That's just one implementation. You could certainly do a > non-recursive implementation. > > Regards, > > Anthony Liguori
What I was saying exactly: we do not need to maintain a stack to skip an indefinite length field, just a nesting counter will do. > >