Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 661474 - app-portage/portage-utils-0.72: buffer underread / array index -1 access
Summary: app-portage/portage-utils-0.72: buffer underread / array index -1 access
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage Utils Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-18 08:53 UTC by Hanno Böck
Modified: 2018-08-01 13:54 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
fix buffer underread in portage-utils (portage-utils-0.72-fix-underread.diff,477 bytes, patch)
2018-07-18 08:53 UTC, Hanno Böck
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hanno Böck gentoo-dev 2018-07-18 08:53:39 UTC
Created attachment 539938 [details, diff]
fix buffer underread in portage-utils

There's a memory safety violation in the portage-utils main.c. This will lead to a crash with memory safety tools like asan.

The problem is in this line:
	if ((*var->value.s)[var->value_len - 1] != '/') {

var->value_len can have the value 0, which will cause an access to the array index -1, which is then pointing outside the allocated buffer.

Catching the special case of var->value_len == 0 should fix this, see attached patch.
Comment 1 Fabian Groffen gentoo-dev 2018-07-18 20:21:31 UTC
Thanks, pushed to master
Comment 2 Larry the Git Cow gentoo-dev 2018-08-01 13:54:06 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=86b8e521983302545dea5c39c5a325d08c635837

commit 86b8e521983302545dea5c39c5a325d08c635837
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-08-01 13:53:47 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-08-01 13:53:47 +0000

    app-portage/portage-utils: version bump to v0.73
    
    Closes: https://bugs.gentoo.org/661762
    Closes: https://bugs.gentoo.org/661474
    Closes: https://bugs.gentoo.org/660508
    Package-Manager: Portage-2.3.40, Repoman-2.3.9

 app-portage/portage-utils/Manifest                                      | 2 +-
 .../{portage-utils-0.71.ebuild => portage-utils-0.73.ebuild}            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)