master - cleanup: validate pointers
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=428b9fcd87d1c79cd4349c884a68de7ccac51981 Commit: 428b9fcd87d1c79cd4349c884a68de7ccac51981 Parent: 7278556c768ae418b03873bd5d9e921e13ce79e8 Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Nov 13 17:40:30 2014 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Thu Nov 13 17:49:42 2014 +0100
cleanup: validate pointers
Mostly on almost impossible to happen paths - but stay safe.
--- lib/activate/dev_manager.c | 3 ++- lib/report/report.c | 4 +++- tools/dmsetup.c | 11 +++++++---- tools/pvresize.c | 4 ++++ 4 files changed, 16 insertions(+), 6 deletions(-)
lib/activate/dev_manager.c +2 -1
@@ -131,7 +131,8 @@ static int _get_segment_status_from_target_params(const char *target_name,if (strcmp (target_name,"cache" ))return 1 ; - segtype =get_segtype_from_string (seg_status->seg->lv->vg->cmd, target_name); +if (!(segtype =get_segtype_from_string (seg_status->seg->lv->vg->cmd, target_name))) + return_0;if (segtype != seg_status->seg->segtype) { log_error(INTERNAL_ERROR "_get_segment_status_from_target_params: "
lib/report/report.c +3 -1
@@ -779,7 +779,9 @@ static int _cachemode_disp(struct dm_report *rh, struct dm_pool *mem, seg =first_seg (seg->pool_lv);if (seg_is_cache_pool (seg)) { - cachemode_str =get_cache_pool_cachemode_name (seg); +if (!(cachemode_str =get_cache_pool_cachemode_name (seg))) + return_0; +return dm_report_field_string (rh, field, &cachemode_str); }
tools/dmsetup.c +7 -4
@@ -3824,13 +3824,15 @@ int main(int argc, char **argv) }if (_switches[HELP_ARG ]) { - cmd =_find_command ("help" ); - goto doit; +if ((cmd =_find_command ("help" ))) + goto doit; + goto unknown; }if (_switches[VERSION_ARG ]) { - cmd =_find_command ("version" ); - goto doit; +if ((cmd =_find_command ("version" ))) + goto doit; + goto unknown; }if (argc ==0 ) {
@@ -3839,6 +3841,7 @@ int main(int argc, char **argv) }if (!(cmd =_find_command (argv[0 ]))) { +unknown:fprintf (stderr,"Unknown command\n" );_usage (stderr); goto out;
tools/pvresize.c +4 -0
@@ -30,6 +30,10 @@ static int _pvresize_single(struct cmd_context *cmd, {struct pvresize_params *params = (struct pvresize_params *) handle; +if (!params) { +log_error (INTERNAL_ERROR "Invalid resize params." ); +return ECMD_FAILED ; + } params->total++;if (!pv_resize_single (cmd, vg, pv, params->new_size))