[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSON/YAML/TOML/etc. parsing performance

From: Eli Zaretskii
Subject: Re: JSON/YAML/TOML/etc. parsing performance
Date: Wed, 04 Oct 2017 08:33:03 +0300

> Cc: address@hidden
> From: Paul Eggert <address@hidden>
> Date: Tue, 3 Oct 2017 13:52:54 -0700
> > > +  if (buffer_and_size->size > PTRDIFF_MAX)
> > > +    xsignal1 (Qoverflow_error, build_string ("buffer too large"));
> > > +  insert (buffer_and_size->buffer, buffer_and_size->size);
> >
> > I don't think we need this test here, as 'insert' already has the
> > equivalent test in one of its subroutines.
> >
> > It can't, because it takes the byte length as ptrdiff_t. We need to 
> > check before whether the size is actually in the valid range of ptrdiff_t.
> A PTRDIFF_MAX test is needed if the JSON library can return strings 
> longer than PTRDIFF_MAX. Please just use buffer_overflow () to signal 
> the error, though.

I'd prefer to have such tests inside 'insert' and its subroutines, or
to tweak the argument passed to 'insert' to have the existing checks
catch the problem.  Can we do that, please?  It doesn't feel right to
me to have this kind of checks in application C code.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]