Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 526596 - app-portage/portage-utils: qatom: invalid atoms not explicitly rejected and wrongly parsed atoms
Summary: app-portage/portage-utils: qatom: invalid atoms not explicitly rejected and w...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Third-Party Tools (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Fabian Groffen
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-23 17:52 UTC by Julian Ospald
Modified: 2018-04-05 19:02 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Ospald 2014-10-23 17:52:06 UTC
# qatom foo-r1

expected result:
(null) foo-r1 (null)
actual result:
(null) foo (null) r1

--

# qatom foo-1-1-r3

expected result:
invalid PN
actual result:
(null) foo-1 1 r3

--

# qatom foo-1.....1

expected result:
invalid PV
actual result:
(null) foo 1.....1

--

# qatom =/dev-bar/foo-1-1-r3

expected result:
debatable, either the operator or the category is invalid, but as a result this atom could also give an error or just (null) for everything
actual result:
dev-bar foo (null) =

--

# qatom foo=foo

expected result:
invalid PN
actual result:
(null) foo=foo (null)

The above example is also true for a LOT of other invalid chars like '#' or '~' etc. It seems there is no check about that whatsoever. Other components like category and slot are probably affected as well.

The valid chars are documented here
https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-160003
Comment 1 Ulrich Müller gentoo-dev 2014-10-23 18:30:29 UTC
Two more examples:

# qatom app-emacs/diff-mode-

expected result:
app-emacs diff-mode- (null)
actual result:
app-emacs diff-mode 

("diff-mode-" is an existing package in the emacs overlay.)

--

# qatom ""

expected result:
invalid PN (no name may be empty)
actual result:
(null)  (null)
Comment 2 SpanKY gentoo-dev 2014-10-23 22:23:34 UTC
atom_explode is written assuming the input is valid.  if you provide garbage, then you get back garbage.  i'm not terribly interested in adding overhead to reject it.

if there are valid atoms that don't parse, then i am interested in it.

why do you care about this ?
Comment 3 Julian Ospald 2014-10-23 22:45:45 UTC
(In reply to SpanKY from comment #2)
> 
> if there are valid atoms that don't parse, then i am interested in it.
> 

The first example in #c0 is a valid atom that is wrongly parsed.
Comment 4 Fabian Groffen gentoo-dev 2018-04-05 12:08:39 UTC
% ./qatom foo-r1       # valid
<unset> foo-r1 <unset>    
% ./qatom foo-1-1-r3   # invalid
<unset> foo 1 r3   
% ./qatom foo-1.....1  # invalid
<unset> foo 1.....1    
% ./qatom =/dev-bar/foo-1-1-r3 # invalid
dev-bar foo 1 r3 = 
% ./qatom foo=foo      # invalid
<unset> foo=foo <unset>    
% ./qatom app-emacs/diff-mode-  # valid
app-emacs diff-mode- <unset>    

In the light of what SpanKY said, invalid atoms aren't detected/rejected, but I fixed the parsing of the valid cases.
Comment 5 Larry the Git Cow gentoo-dev 2018-04-05 12:10:44 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=89a388678c4975b541d24931b0916e2959ed70be

commit 89a388678c4975b541d24931b0916e2959ed70be
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-04-05 12:10:26 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-04-05 12:10:26 +0000

    atom_explode: fix parsing of some valid corner cases
    
    Extract the version part of the atom, such that we can more reliably
    parse the version components without worrying about accidentially taking
    parts of the package name.
    
    Bug: https://bugs.gentoo.org/526596

 libq/atom_explode.c | 78 +++++++++++++++++++++++++++++------------------------
 tests/qatom/dotest  | 13 ++++++---
 2 files changed, 53 insertions(+), 38 deletions(-)}
Comment 6 Larry the Git Cow gentoo-dev 2018-04-05 19:02:51 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=34b636503cc7dcabe32b9b377c2eb77cb5fd5575

commit 34b636503cc7dcabe32b9b377c2eb77cb5fd5575
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-04-05 19:02:10 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-04-05 19:02:34 +0000

    app-portage/portage-utils: version bump to 0.70
    
    This release fixes multiple bugs lingering around for a while.
    
    Closes: https://bugs.gentoo.org/651546
    Closes: https://bugs.gentoo.org/646310
    Closes: https://bugs.gentoo.org/645554
    Closes: https://bugs.gentoo.org/643820
    Closes: https://bugs.gentoo.org/638032
    Closes: https://bugs.gentoo.org/608960
    Closes: https://bugs.gentoo.org/607498
    Closes: https://bugs.gentoo.org/558306
    Closes: https://bugs.gentoo.org/526596
    Closes: https://bugs.gentoo.org/470168
    Closes: https://bugs.gentoo.org/351100
    Closes: https://bugs.gentoo.org/335453
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 app-portage/portage-utils/Manifest                 |  2 +-
 .../portage-utils/portage-utils-0.62.ebuild        |  2 +-
 .../portage-utils/portage-utils-0.63.ebuild        | 43 ----------------------
 ...ls-0.64-r1.ebuild => portage-utils-0.70.ebuild} | 16 +-------
 4 files changed, 4 insertions(+), 59 deletions(-)