[CRIU] [PATCH] crtools: Make sure the option has been strdup'ed
Pavel Emelyanov
xemul at parallels.com
Wed Oct 9 08:27:12 PDT 2013
On 10/09/2013 01:28 PM, Cyrill Gorcunov wrote:
> At this moment (parsing of options on startup) we're
> hardly if ever get problem with strdup. Still to be
> consistent with the rest of the program code do
>
> - use xstrdup, to print error message if we failed
> - emergency exit from program on error
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> crtools.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/crtools.c b/crtools.c
> index c2c3981..d99bc0c 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -162,7 +162,9 @@ int main(int argc, char *argv[])
> }
> break;
> case 'o':
> - opts.output = strdup(optarg);
> + opts.output = xstrdup(optarg);
Do we need to strdup it at all?
> + if (!opts.output)
> + return -1;
> if (log_init(optarg))
> return -1;
> log_inited = 1;
>
More information about the CRIU
mailing list