svn commit: r350309 - head/sbin/nvmecontrol
Warner Losh
imp at FreeBSD.org
Wed Jul 24 23:04:27 UTC 2019
Author: imp
Date: Wed Jul 24 23:04:26 2019
New Revision: 350309
URL: https://svnweb.freebsd.org/changeset/base/350309
Log:
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:
head/sbin/nvmecontrol/comnd.c
head/sbin/nvmecontrol/logpage.c
Modified: head/sbin/nvmecontrol/comnd.c
==============================================================================
--- head/sbin/nvmecontrol/comnd.c Wed Jul 24 22:57:17 2019 (r350308)
+++ head/sbin/nvmecontrol/comnd.c Wed Jul 24 23:04:26 2019 (r350309)
@@ -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: head/sbin/nvmecontrol/logpage.c
==============================================================================
--- head/sbin/nvmecontrol/logpage.c Wed Jul 24 22:57:17 2019 (r350308)
+++ head/sbin/nvmecontrol/logpage.c Wed Jul 24 23:04:26 2019 (r350309)
@@ -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-all
mailing list