From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 80361138334 for ; Wed, 18 Jul 2018 20:20:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 34E5AE087A; Wed, 18 Jul 2018 20:20:40 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 04A68E087A for ; Wed, 18 Jul 2018 20:20:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 03292335C42 for ; Wed, 18 Jul 2018 20:20:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 49A6536B for ; Wed, 18 Jul 2018 20:20:36 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1531944214.de6b2ac12e02c690f8dee2517af1c09b436f5fc9.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: main.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: de6b2ac12e02c690f8dee2517af1c09b436f5fc9 X-VCS-Branch: master Date: Wed, 18 Jul 2018 20:20:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 7e5316d3-c3ae-434b-8192-789796b8d36b X-Archives-Hash: dc82cc5f318f21beee1c750b9fbd299c commit: de6b2ac12e02c690f8dee2517af1c09b436f5fc9 Author: Hanno Boeck gentoo org> AuthorDate: Wed Jul 18 20:03:34 2018 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Wed Jul 18 20:03:34 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=de6b2ac1 main: fix potential buffer underrun Signed-off-by: Fabian Groffen gentoo.org> main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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';