aboutsummaryrefslogtreecommitdiffstats
path: root/main/openrc/0001-librc-fix-off-by-one-bug.patch
blob: 96201eac45d7c0c1fde5fa9a52959bdc7eae6b8d (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
27
28
29
From 08cde40ee9abe9d3659133dfa9b10f609a13db20 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 26 Sep 2013 07:58:12 +0000
Subject: [PATCH] librc: fix off-by-one bug

We need allocate space for both the added leading '-' and the trailing
'\0'.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 src/librc/librc-depend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index ac93716..c9df451 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -856,7 +856,7 @@ rc_deptree_update(void)
 	 * work for them. This doesn't stop them from being run directly. */
 	if (sys) {
 		len = strlen(sys);
-		nosys = xmalloc(len + 1);
+		nosys = xmalloc(len + 2);
 		nosys[0] = '-';
 		for (i = 0; i < len; i++)
 			nosys[i + 1] = (char)tolower((unsigned char)sys[i]);
-- 
1.8.4