aboutsummaryrefslogtreecommitdiffstats
path: root/main/apk-tools/0002-db-catch-asprintf-failure.patch
blob: ede2765a2095bf993715620aafd870cd58425d6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From 5f6e963680b8f4ef9a036ea44483b8dcca3c6ce2 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 13 Mar 2017 12:57:43 +0000
Subject: [PATCH 2/2] db: catch asprintf failure

---
 src/database.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/database.c b/src/database.c
index 356907e..80b80e9 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1576,7 +1576,8 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
 			apk_blob_to_file(db->root_fd, apk_arch_file, *db->arch, APK_BTF_ADD_EOL);
 
 		/* mount /proc */
-		asprintf(&db->root_proc_dir, "%s/proc", dbopts->root);
+		if (asprintf(&db->root_proc_dir, "%s/proc", dbopts->root) == -1)
+			goto ret_errno;
 		if (statfs(db->root_proc_dir, &stfs) != 0) {
 			if (errno == ENOENT) mkdir(db->root_proc_dir, 0555);
 			stfs.f_type = 0;
-- 
2.11.1