summaryrefslogtreecommitdiffstats
path: root/src/fetch.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-06-11 09:21:17 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-06-11 09:21:17 +0000
commit3646350479b960602c53ed45b21be771e7c3f43c (patch)
tree5ef3ac9b1e4db0374306f927bcb36364d5c7923c /src/fetch.c
parent64a85ec65d7906faaf75928e5a105b2ea315e154 (diff)
downloadapk-tools-3646350479b960602c53ed45b21be771e7c3f43c.tar.bz2
apk-tools-3646350479b960602c53ed45b21be771e7c3f43c.tar.xz
fetch: readlink does not end buffer with \0
According the manpage readlink(2) does not append a null byte to buf. So we have to do it ourselves.
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fetch.c b/src/fetch.c
index 5cea5db..ad3a67c 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -91,7 +91,10 @@ static int fetch_package(struct fetch_ctx *fctx,
} else {
if ((fctx->flags & FETCH_LINK) && apk_url_local_file(infile)) {
char real_infile[256];
- readlink(infile, real_infile, sizeof(real_infile));
+ int n;
+ n = readlink(infile, real_infile, sizeof(real_infile));
+ if (n > 0 && n < sizeof(real_infile))
+ real_infile[n] = '\0';
if (link(real_infile, outfile) == 0)
return 0;
}