aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanno Boeck <hanno@gentoo.org>2018-07-18 22:03:34 +0200
committerFabian Groffen <grobian@gentoo.org>2018-07-18 22:03:34 +0200
commitde6b2ac12e02c690f8dee2517af1c09b436f5fc9 (patch)
tree83c8b877d8a8acc2471828c4b160670368c63e22
parentMerge pull request #3 from hoefling/readme-fix (diff)
downloadportage-utils-de6b2ac12e02c690f8dee2517af1c09b436f5fc9.tar.gz
portage-utils-de6b2ac12e02c690f8dee2517af1c09b436f5fc9.tar.bz2
portage-utils-de6b2ac12e02c690f8dee2517af1c09b436f5fc9.zip
main: fix potential buffer underrun
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main.c b/main.c
index 7dbdbe7..30dd063 100644
--- a/main.c
+++ b/main.c
@@ -969,7 +969,7 @@ initialize_portage_env(void)
/* Make sure ROOT always ends in a slash */
var = &vars_to_read[0];
- if ((*var->value.s)[var->value_len - 1] != '/') {
+ if (var->value_len == 0 || (*var->value.s)[var->value_len - 1] != '/') {
portroot = xrealloc(portroot, var->value_len + 2);
portroot[var->value_len] = '/';
portroot[var->value_len + 1] = '\0';