[PATCH] nvmecontrol: Fix shortopts allocation
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Sep 11 08:28:38 UTC 2019
Account for potential ':' in the short options string.
---
sbin/nvmecontrol/comnd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sbin/nvmecontrol/comnd.c b/sbin/nvmecontrol/comnd.c
index d8d97ad11b5..a91969ff766 100644
--- a/sbin/nvmecontrol/comnd.c
+++ b/sbin/nvmecontrol/comnd.c
@@ -189,7 +189,7 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
lopts = malloc((n + 2) * sizeof(struct option));
if (lopts == NULL)
err(1, "option memory");
- p = shortopts = malloc((n + 3) * sizeof(char));
+ p = shortopts = malloc((2 * n + 2) * sizeof(char));
if (shortopts == NULL)
err(1, "shortopts memory");
idx = 0;
--
2.16.4
More information about the freebsd-hackers
mailing list