Re: [PATCH 54/67] color: add overflow checks for parsing colors
From: Junio C Hamano <hidden>
Date: 2016-06-15 23:06:38
Jeff King [off-list ref] writes:
On Fri, Sep 18, 2015 at 02:54:11PM -0400, Eric Sunshine wrote:quoted
quoted
@@ -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 ;-)