fix: V-001 security vulnerability

Automated security fix generated by OrbisAI Security

Signed-off-by: orbisai0security <mediratta01.pally@gmail.com>
This commit is contained in:
orbisai0security 2026-05-21 05:58:46 +00:00
parent b3f06c1774
commit d252b7fcf1
2 changed files with 8 additions and 3 deletions

View file

@ -344,11 +344,12 @@ obsolete(int *argcp, char **argvp[])
warnx("option requires an argument -- %c", *ap);
usage();
}
if ((nargv[0] = malloc(strlen(*argv) + 2 + 1)) == NULL)
size_t len = strlen(*argv);
if ((nargv[0] = malloc(len + 2 + 1)) == NULL)
err(1, NULL);
nargv[0][0] = '-';
nargv[0][1] = *ap;
(void)strcpy(&nargv[0][2], *argv);
memcpy(&nargv[0][2], *argv, len + 1);
++argv;
++nargv;
break;

View file

@ -398,7 +398,11 @@ again:
return;
}
if (buf[0] != '\n') {
(void) strcpy(magtape, buf);
free(magtape);
if ((magtape = strdup(buf)) == NULL) {
fprintf(stderr, "Cannot allocate space for tape name\n");
done(1);
}
magtape[strlen(magtape) - 1] = '\0';
}
if (pipecmdin) {