diff options
author | eadler <eadler@FreeBSD.org> | 2012-12-08 18:41:16 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2012-12-08 18:41:16 +0000 |
commit | 2e821afa0e6898492aaacd4824b629319c124b42 (patch) | |
tree | ea5ec6d15458084a0979d6c07174c274f123c17e /usr.bin/fetch/fetch.c | |
parent | 26d78ae2210b759029117ea30252c32bb31d78fa (diff) | |
download | FreeBSD-src-2e821afa0e6898492aaacd4824b629319c124b42.zip FreeBSD-src-2e821afa0e6898492aaacd4824b629319c124b42.tar.gz |
Add check for failure of mkstemp and setenv.
Reviewed by: des
Approved by: cperciva (implicit)
Obtained from: DragonFlyBSD
MFC after: 1 week
Diffstat (limited to 'usr.bin/fetch/fetch.c')
-rw-r--r-- | usr.bin/fetch/fetch.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index 336df97..025fcdc 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -618,7 +618,10 @@ fetch(char *URL, const char *path) asprintf(&tmppath, "%.*s.fetch.XXXXXX.%s", (int)(slash - path), path, slash); 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"); chown(tmppath, sb.st_uid, sb.st_gid); chmod(tmppath, sb.st_mode & ALLPERMS); @@ -988,7 +991,8 @@ main(int argc, char *argv[]) if (v_tty) fetchAuthMethod = query_auth; 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) { if ((p = strrchr(*argv, '/')) == NULL) |