[systemd-devel] [PATCH] networkd: use valid bus paths

Tom Gundersen teg at jklm.no
Tue Feb 10 13:33:15 PST 2015


On Tue, Feb 10, 2015 at 9:02 PM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 06.02.15 22:35, Mantas Mikulėnas (grawity at gmail.com) wrote:
>
>> Object path components must start with [A-Za-z_] (AFAIK).
>> Also the value of 'p' is undefined if asprintf fails.
>
> Well, asprintf() the way glibc defines it does not clobber the
> passed-in pointer on failure. We rely on that all over the code, and I
> am pretty sure that's the right thing to do. The man page of
> asprintf() is a bit misleading in this case, and the info page doesn't
> mention this at all. The glibc sources tell show that they indeed
> don't clobber the pointer on failure.
>
> Given that p was initialized to NULL the check Tom had in place
> originally is OK hence.
>
> And even if glibc asprintf() would clobber passed in pointers on
> failure, the right fix would really be to write a small wrapper that
> corrects that, and use that everywhere instead of patching this
> individually on each invocation...

For the record: This has now all been refactored to use
sd_bus_path_{en,de}code, so the issues no longer apply. Thanks for
looking at it though!

Cheers,

Tom


More information about the systemd-devel mailing list