[systemd-devel] [PATCH] localed: forward xkbcommon errors

Lennart Poettering lennart at poettering.net
Sun Nov 30 15:59:02 PST 2014


On Tue, 25.11.14 10:01, David Herrmann (dh.herrmann at gmail.com) wrote:

> char fmt[LINE_MAX];
> 
> snprintf(fmt, sizeof(fmt), "libxkbcommon: %s", format);
> e = xkb_context_get_user_data(ctx);
> bus_error_setfv(e, SD_BUS_ERROR_INVALID_ARGS, fmt, args);
> 
> We use LINE_MAX as explicit limit on a lot of these calls (and I think
> it makes sense to prevent unbound allocations).

I think "strappenda()" is more appropriate. Format strings are
generally *not* unbounded in their length.

LINE_MAX is the best way to chicken out of doing precise allocations
of things, but it's still chickening out. And since format strings ar
not unbounded in their size we really should use strappenda() for
it. And if not, then at least "strappend()"...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list