From 43cb554c3fd94ba394b708265c5fa2225a37a9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Fri, 11 Jun 2010 13:42:21 +0300 Subject: various: use O_CLOEXEC and add some error checking --- src/fetch.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/fetch.c') diff --git a/src/fetch.c b/src/fetch.c index b7da2f5..9c32a11 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -62,9 +62,7 @@ static int cup(void) unsigned long len = sizeof(buf); uncompress(buf, &len, z, sizeof(z)); - write(STDOUT_FILENO, buf, len); - - return 0; + return write(STDOUT_FILENO, buf, len) != len; } static int fetch_parse(void *ctx, struct apk_db_options *dbopts, @@ -83,7 +81,7 @@ static int fetch_parse(void *ctx, struct apk_db_options *dbopts, fctx->flags |= FETCH_LINK; break; case 'o': - fctx->outdir_fd = openat(AT_FDCWD, optarg, O_RDONLY); + fctx->outdir_fd = openat(AT_FDCWD, optarg, O_RDONLY | O_CLOEXEC); break; default: return -1; @@ -136,7 +134,7 @@ static int fetch_package(struct fetch_ctx *fctx, return 0; } fd = openat(fctx->outdir_fd, pkgfile, - O_CREAT|O_RDWR|O_TRUNC, 0644); + O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0644); if (fd < 0) { apk_error("%s: %s", pkgfile, strerror(errno)); return -1; -- cgit v1.2.3