[CRIU] [PATCH] zdtm: Pick up deleted unix socket test

Pavel Emelyanov xemul at parallels.com
Thu Jul 3 12:45:22 PDT 2014


On 07/03/2014 07:58 PM, Filipe Brandenburger wrote:
> On Thu, Jul 3, 2014 at 7:34 AM, Pavel Emelyanov <xemul at parallels.com> wrote:
>> +       cwd = get_current_dir_name();
>> +       if (strlen(filename) + strlen(cwd) >= sizeof(name->sun_path))
>>                 return -1;
> 
> This is now more likely to fail due to the fairly short limit on the
> file name (108 bytes IIRC). Any chance this could fallback to
> something like "/tmp" or getenv("TMPDIR") if the resulting pathname is
> too long?

Yes, you're right. But this deserves some helper in the lib.c because
we have several tests that generate unix socket name that way.

I'll try to address that incrementally :)

> Alternatively, you could check if filename is an absolute path and not
> prepend cwd in that case (or just fail altogether) and leave the job
> to find an adequate filename to the script that calls it.

The script is the Makefile and the guy is pretty stupid :) It just
appends .test to the test name and feeds on a file/dir name.

> (BTW, there's also an off-by-one error in the length check now since
> you're adding an extra "/" to the string. You probably want a +1 in
> the lengths there. A maybe more flexible approach is using snprintf
> and checking if the return value is >= the size of the string in which
> case it means it was truncated.)

Ouch, indeed. Will fix.

Thanks,
Pavel



More information about the CRIU mailing list