svn commit: r350938 - stable/12/sbin/nvmecontrol
Alexander Motin
mav at FreeBSD.org
Mon Aug 12 18:56:12 UTC 2019
Author: mav
Date: Mon Aug 12 18:56:11 2019
New Revision: 350938
URL: https://svnweb.freebsd.org/changeset/base/350938
Log:
MFC r350309 (by imp): Fix several related coverity issues:
Make sure to always free shortopts and lopts when returning.
Fix minor logic bug to guard against NULLs properly.
CID: 1403654, 1403656, 1403658
Modified:
stable/12/sbin/nvmecontrol/comnd.c
stable/12/sbin/nvmecontrol/logpage.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sbin/nvmecontrol/comnd.c
==============================================================================
--- stable/12/sbin/nvmecontrol/comnd.c Mon Aug 12 18:55:36 2019 (r350937)
+++ stable/12/sbin/nvmecontrol/comnd.c Mon Aug 12 18:56:11 2019 (r350938)
@@ -155,7 +155,7 @@ find_long(struct option *lopts, int ch)
for (i = 0; lopts[i].val != ch && lopts[i].name != NULL; i++)
continue;
- return i;
+ return (i);
}
int
@@ -251,6 +251,8 @@ arg_parse(int argc, char * const * argv, const struct
if (optind >= argc) {
fprintf(stderr, "Missing arg %s\n", args->descr);
arg_help(argc, argv, f);
+ free(lopts);
+ free(shortopts);
return (1);
}
*(char **)args->ptr = argv[optind++];
@@ -258,10 +260,12 @@ arg_parse(int argc, char * const * argv, const struct
}
}
free(lopts);
+ free(shortopts);
return (0);
bad_arg:
fprintf(stderr, "Bad value to --%s: %s\n", opts[idx].long_arg, optarg);
free(lopts);
+ free(shortopts);
exit(1);
}
Modified: stable/12/sbin/nvmecontrol/logpage.c
==============================================================================
--- stable/12/sbin/nvmecontrol/logpage.c Mon Aug 12 18:55:36 2019 (r350937)
+++ stable/12/sbin/nvmecontrol/logpage.c Mon Aug 12 18:56:11 2019 (r350938)
@@ -465,7 +465,7 @@ logpage(const struct cmd *f, int argc, char *argv[])
* unless the vendors match.
*/
SLIST_FOREACH(lpf, &logpages, link) {
- if (lpf->vendor != NULL && vendor != NULL &&
+ if (lpf->vendor == NULL || vendor == NULL ||
strcmp(lpf->vendor, vendor) != 0)
continue;
if (opt.page != lpf->log_page)
More information about the svn-src-stable-12
mailing list