Re: [PATCH 54/67] color: add overflow checks for parsing colors
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 21, 2015, 16:56 UTC
- Message-ID
- <xmqqlhbzbtjt.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20150918190116.GA3932@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> On Fri, Sep 18, 2015 at 02:54:11PM -0400, Eric Sunshine wrote:
>
>> > @@ -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).A tangent. quote.c does EMIT semi-carefully, but gets sloppy when it does a similar thing for EMITBUF.
Perhaps it should go to somebody's low-hanging-fruit list ;-)