Re: [PATCH] Properly handle \0 delimited string lists

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



On Wed, Jun 11, 2014 at 11:10:39PM +1000, David Gibson wrote:
> Hi Jack,
> 
> Long time no see :).

Yeah, I was pretty pleased to have an excuse to send something your way =)

> 
> On Tue, Jun 10, 2014 at 02:57:36PM -0500, Jack Miller wrote:
> > reserved-names="res1\0res2\0res3";
> > 
> > Is valid DTS. This one-liner expands data based on the len given by the lexer
> > instead of strlen.
> > 
> > Without this patch, realloc gets confused and hangs. For example:
> > 
> > *** Error in `./dtc': realloc(): invalid next size: 0x0000000001961670
> > ***
> 
> So.. the patch certainly isn't wrong, and is arguably safer than the
> current version.
> 
> But.. I haven't been able to reproduce the problem, and I don't really
> see how it would occur in the first place.
> 
> The thing we're taking a strlen of is the input with it's escapes, so
> it won't have NULs, just backslashes and 0 digits.
> 
> Or am I missing something?

Sorry, I was unclear. The \0 was my short hand for a real embedded NULL
character, which may be intentionally wrong-headed, but I don't think it's
invalid (or if it is invalid, should at least not cause the compiler to do
bad things).

In refining my testcase I realized that it doesn't fail on realloc with all
bad input, but it does generate mangled output otherwise.

I've uploaded two short .dts snippets just because pasting NULLs into an
email seems like a bad idea:

http://codezen.org/static/broken-dts.tar.gz

One causes the realloc, the other causes the mangled output on git HEAD. Both
are working properly with my patch.

- Jack
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux