[CRIU] Off by one in mnt_get_sibling_path()
Kirill Tkhai
ktkhai at virtuozzo.com
Thu Sep 22 00:56:37 PDT 2016
On 21.09.2016 20:04, Andrew Vagin wrote:
> On Tue, Sep 20, 2016 at 05:17:27PM +0300, Kirill Tkhai wrote:
>> Hi,
>>
>> int off = 0;
>>
>> ...
>>
>> if (p->mountpoint[1] != 0) /* not "/" */
>> off = snprintf(path, len, "%s", p->mountpoint);
>> if (path[off - 1] == '/') /* p->mountpoint = "./" */
>>
>> ^^^
>> The above looks like off-by-one when off == 0. Is there is
>> a condition which guarantees that off is not zero?
>
> p->mountpoint can't be "". snprintf returns the number of characters
> printed, so it should be ok
But why are you speaking about ""? It's about "/" according to code comment.
More information about the CRIU
mailing list