]> git.puffer.fish Git - matthieu/frr.git/commit
lib, vtysh: Fix memory leaks, change cmd_element to const
authorQuentin Young <qlyoung@cumulusnetworks.com>
Sat, 12 Nov 2016 01:06:32 +0000 (01:06 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Sat, 12 Nov 2016 01:06:32 +0000 (01:06 +0000)
commit17aca20bfbb9d7e980a04c9b017f87f027901839
tree86e31be2464ae41c3125400a161b87d34419d098
parent90e9905f07695fd32696f3d543cbe4ed432263b6
lib, vtysh: Fix memory leaks, change cmd_element to const

Fix a few memory issues:

* Not freeing tab-completions upon input match failure
* Invalid write when null-terminating tab-completions
* Not freeing argv[] itself in additinon to elements
* Use XFREE() instead of free() as appropriate
* Not freeing final token of an [option] during parsing

Make a few minor changes to CLI internals:

* Improve documentation on matching & completion functions
* Only make one copy of cmd_token's when building argv,
  instead of three
* Don't make a copy of the matching cmd_element

Make one major(ish) change to CLI internals:

* Change all pointers to struct cmd_element to const

Code outside of the core CLI units should never have an
occasion to modify the internal state of the command system.
Doing so could easily amount to having a CLI interface that
changes during runtime, and could conceivably lead to security
issues. Explicitly disallowing this removes any chance of
confusion.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/command.c
lib/command.h
lib/command_match.c
lib/command_match.h
lib/command_parse.y
vtysh/vtysh.c