summaryrefslogtreecommitdiffstats
path: root/src/fetch.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-06-11 13:42:21 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-06-11 13:42:21 +0300
commit43cb554c3fd94ba394b708265c5fa2225a37a9eb (patch)
treeff9708008237754d46c3c2188cdb866a4d0fd195 /src/fetch.c
parentbcbe575c3b28997a03a65426b241bdfef4d8b747 (diff)
downloadapk-tools-43cb554c3fd94ba394b708265c5fa2225a37a9eb.tar.bz2
apk-tools-43cb554c3fd94ba394b708265c5fa2225a37a9eb.tar.xz
various: use O_CLOEXEC and add some error checking
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c8
1 files changed, 3 insertions, 5 deletions
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;