Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Avoid possible race condition when using mktemp()
Marin Atanasov Nikolov committed 14 years ago
commit 1c5352fa58f2608f23f3053137f6ae9e55cafa75
parent e2e7497
1 file changed +2 -3
modified libpkg/fetch.c
@@ -29,10 +29,9 @@ pkg_fetch_file(const char *url, const char *dest)
	char buf[10240];
	int retcode = EPKG_OK;

-
	if ((fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
+
	if ((fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0600)) == -1) {
		EMIT_ERRNO("open", dest);
-
		retcode = EPKG_FATAL;
-
		goto cleanup;
+
		return(EPKG_FATAL);
	}

	while (remote == NULL) {