Add check for failure of mkstemp and setenv.
Reviewed by: des Approved by: cperciva (implicit) Obtained from: DragonFlyBSD MFC after: 1 week
This commit is contained in:
parent
689f0bd93b
commit
2214137ab1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=244037
@ -618,7 +618,10 @@ fetch(char *URL, const char *path)
|
|||||||
asprintf(&tmppath, "%.*s.fetch.XXXXXX.%s",
|
asprintf(&tmppath, "%.*s.fetch.XXXXXX.%s",
|
||||||
(int)(slash - path), path, slash);
|
(int)(slash - path), path, slash);
|
||||||
if (tmppath != NULL) {
|
if (tmppath != NULL) {
|
||||||
mkstemps(tmppath, strlen(slash) + 1);
|
if (mkstemps(tmppath, strlen(slash) + 1) == -1) {
|
||||||
|
warn("%s: mkstemps()", path);
|
||||||
|
goto failure;
|
||||||
|
}
|
||||||
of = fopen(tmppath, "w");
|
of = fopen(tmppath, "w");
|
||||||
chown(tmppath, sb.st_uid, sb.st_gid);
|
chown(tmppath, sb.st_uid, sb.st_gid);
|
||||||
chmod(tmppath, sb.st_mode & ALLPERMS);
|
chmod(tmppath, sb.st_mode & ALLPERMS);
|
||||||
@ -988,7 +991,8 @@ main(int argc, char *argv[])
|
|||||||
if (v_tty)
|
if (v_tty)
|
||||||
fetchAuthMethod = query_auth;
|
fetchAuthMethod = query_auth;
|
||||||
if (N_filename != NULL)
|
if (N_filename != NULL)
|
||||||
setenv("NETRC", N_filename, 1);
|
if (setenv("NETRC", N_filename, 1) == -1)
|
||||||
|
err(1, "setenv: cannot set NETRC=%s", N_filename);
|
||||||
|
|
||||||
while (argc) {
|
while (argc) {
|
||||||
if ((p = strrchr(*argv, '/')) == NULL)
|
if ((p = strrchr(*argv, '/')) == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user