1 |
commit: de6b2ac12e02c690f8dee2517af1c09b436f5fc9 |
2 |
Author: Hanno Boeck <hanno <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jul 18 20:03:34 2018 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jul 18 20:03:34 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=de6b2ac1 |
7 |
|
8 |
main: fix potential buffer underrun |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
main.c | 2 +- |
13 |
1 file changed, 1 insertion(+), 1 deletion(-) |
14 |
|
15 |
diff --git a/main.c b/main.c |
16 |
index 7dbdbe7..30dd063 100644 |
17 |
--- a/main.c |
18 |
+++ b/main.c |
19 |
@@ -969,7 +969,7 @@ initialize_portage_env(void) |
20 |
|
21 |
/* Make sure ROOT always ends in a slash */ |
22 |
var = &vars_to_read[0]; |
23 |
- if ((*var->value.s)[var->value_len - 1] != '/') { |
24 |
+ if (var->value_len == 0 || (*var->value.s)[var->value_len - 1] != '/') { |
25 |
portroot = xrealloc(portroot, var->value_len + 2); |
26 |
portroot[var->value_len] = '/'; |
27 |
portroot[var->value_len + 1] = '\0'; |