zfs, zpool: safe_malloc() duplicate argv

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-08 22:50:45 +01:00 committed by Brian Behlendorf
parent 84a3eab6aa
commit a3dcc0aa0c
2 changed files with 2 additions and 2 deletions

View File

@ -8697,7 +8697,7 @@ main(int argc, char **argv)
* Many commands modify input strings for string parsing reasons. * Many commands modify input strings for string parsing reasons.
* We create a copy to protect the original argv. * We create a copy to protect the original argv.
*/ */
newargv = malloc((argc + 1) * sizeof (newargv[0])); newargv = safe_malloc((argc + 1) * sizeof (newargv[0]));
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
newargv[i] = strdup(argv[i]); newargv[i] = strdup(argv[i]);
newargv[argc] = NULL; newargv[argc] = NULL;

View File

@ -10924,7 +10924,7 @@ main(int argc, char **argv)
* Many commands modify input strings for string parsing reasons. * Many commands modify input strings for string parsing reasons.
* We create a copy to protect the original argv. * We create a copy to protect the original argv.
*/ */
newargv = malloc((argc + 1) * sizeof (newargv[0])); newargv = safe_malloc((argc + 1) * sizeof (newargv[0]));
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
newargv[i] = strdup(argv[i]); newargv[i] = strdup(argv[i]);
newargv[argc] = NULL; newargv[argc] = NULL;