]> sourceware.org Git - lvm2.git/commit
lvmcmdline: return 0/NULL if cmd->arg_values not set and arg_count/grouped_arg_count...
authorPeter Rajnoha <prajnoha@redhat.com>
Thu, 4 Aug 2016 07:32:05 +0000 (09:32 +0200)
committerPeter Rajnoha <prajnoha@redhat.com>
Tue, 9 Aug 2016 16:24:45 +0000 (18:24 +0200)
commit5649834f7d62b9cba3b06c1b5d0dd425978f3ad2
tree9796aa710e2241cfddf06f45730adac1c49129eb
parent1fde4bf4d08cbf579dbbe5eb08661eac67eb68f7
lvmcmdline: return 0/NULL if cmd->arg_values not set and arg_count/grouped_arg_count/arg_value called

We may call arg_count/grouped_arg_count/arg_value soon enough that
cmd->arg_values is not set yet.

Normally, when running a command, we execute lvm_run_command which in
turn calls _process_command_line to allocate and parse the command line
values and stores them in cmd->arg_values.

However, if we run lvm shell, this one doesn't accept any command line
options and we parse the command line for each command that is executed
within the lvm shell then. If we used any code that tries to access
cmd->arg_values through any of the the arg handling functions too
early, we could end up with a segfault due to uninitialized (NULL)
cmd->arg_values.

This patch just saves extra checks in all the code where arg handling
may be called too early so that the cmd->arg_values is not set up yet.
This does not apply to any of existing code, but subsequent patches
will need that.
tools/lvmcmdline.c
This page took 0.039543 seconds and 5 git commands to generate.