tools/xl: Fix segfaults from `xl psr-cat-cbm-set` command line handling
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Jul 2015 19:32:45 +0000 (20:32 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 17 Jul 2015 10:05:55 +0000 (11:05 +0100)
commita49077e52b2d7c1a9d9a8f0a1fc55cf742039a36
tree689c74cc02dd0284549f5e609c8665de33c2824e
parent74c022b6eb46da747c280b6fdc370754864eef3a
tools/xl: Fix segfaults from `xl psr-cat-cbm-set` command line handling

The socket option takes a mandatory argument.  Mark it as such, so
optarg isn't NULL when passed to trim(), which unconditionally
dereference it.

Range check optind against argc before blindly assuming that
argv[optind] and argv[optind+1] exist.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c