[CRIU] [PATCH] criu-util: do not double free and simplify xvstrcat

Dmitry Safonov dsafonov at virtuozzo.com
Fri Jul 15 12:03:20 PDT 2016


On 07/15/2016 09:46 PM, Dmitry Safonov wrote:
> There is a bug, that if vsnprintf() wrote nothing to buffer:
> that may be xstrcat(0, "%s", "") or something like that,
> than vsnprintf's return value is 0, which will be lesser than
> delta. The code before would do following:
> o first cycle:
>   1. relocate str to new (str is not allocated anymore)
>   2. vsnprintf() retured 0, delta is greater.
> o second cycle:
>   1. relocate previously freed str to new..^C ^C
> Segmentation fault (core dumped)
>
> Weeell, I do think, we can do better job here.
>
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
I will resend v2 for this, heh.


More information about the CRIU mailing list