Re: [PATCH v5 03/15] pkt-line: add `gentle` parameter to format_packet()
- From
Jeff King <peff@peff.net>
- Date
- Aug 10, 2016, 14:34 UTC
- Message-ID
- <20160810143452.siolzmqwgs3xzcal@sigill.intra.peff.net>
- In-Reply-To
- <982CD9A4-E155-4DEE-9B47-BCEA4F0C493C@gmail.com>
On Wed, Aug 10, 2016 at 03:59:19PM +0200, Lars Schneider wrote:
Show 15 quoted lines
> > It does still feel a little weird that you cannot tell the difference
> > between a write() error and bad input. Because you really might want to
> > do something different between the two. Like:
> >
> > #define MAX_FILENAME (PKTLINE_DATA_MAXLEN - strlen("filename"))
> >
> > if (filename > MAX_FILENAME) {
> > warning("woah, that name is ridiculous; truncating");
> > ret = packet_write_fmt_gently(fd, "%.*s", MAX_FILENAME, filename);
> > } else
> > ret = packet_write_fmt_gently(fd, "%s", filename);
>
>
> I can do that. However, I wouldn't truncate the filename as this
> might create a weird outcome. I would just let the filter fail.Yeah, I think that is probably fine (I don't have a real opinion for this particular case, but was mostly just trying to think about whether the pktline interface was suitably flexible).
-Peff