Re: [PATCH 54/67] color: add overflow checks for parsing colors
- From
Jeff King <peff@peff.net>
- Date
- Sep 18, 2015, 19:01 UTC
- Message-ID
- <20150918190116.GA3932@sigill.intra.peff.net>
- In-Reply-To
- <CAPig+cQUwsDfL-epJYy+4xoG2-GfDfhb3mH=7WAzYbsea-sXDA@mail.gmail.com>
On Fri, Sep 18, 2015 at 02:54:11PM -0400, Eric Sunshine wrote:
Show 15 quoted lines
> > @@ -224,12 +227,18 @@ int color_parse_mem(const char *value, int value_len, char *dst)
> > goto bad;
> > }
> >
> > +#define OUT(x) do { \
> > + if (dst == end) \
> > + die("BUG: color parsing ran out of space"); \
> > + *dst++ = (x); \
> > +} while(0)
>
> Hmm, can we have an #undef OUT before the #define OUT(...), or choose
> a less conflict-likely name? In particular, I'm thinking about
> preprocessor namespace pollution arising from sources out of our
> control, such as was the case with 414382f (ewah/bitmap: silence
> warning about MASK macro redefinition, 2015-06-03).Sure. I wouldn't think any headers would be dumb enough to define something as short and common as OUT. But then I would have said the same about MASK. ;)
I added an #undef, and I added an #undef at the end of the function, as well (to clean up after ourselves).
-Peff