From 3646350479b960602c53ed45b21be771e7c3f43c Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 11 Jun 2009 09:21:17 +0000 Subject: 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. --- src/fetch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/fetch.c') 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; } -- cgit v1.2.3