public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] portage.manifest: Fix mis-parsing Manifests with numerical checksums
@ 2017-11-19 17:12 Michał Górny
  2017-11-19 23:10 ` Zac Medico
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2017-11-19 17:12 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Fix the regular expression used to parse Manifests not to fail horribly
when one of the checksums accidentally happens to be all-digits.

The previously used regular expression used to greedily take everything
up to the first number as filename. If one of the checksums happened to
be purely numeric, this meant that everything up to that checksum was
taken as filename, and the checksum itself was taken as file size. It
was also capable of accepting an empty filename.

The updated regular expression uses '\S+' to match filenames. Therefore,
the match is terminated on first whitespace character and filenames can
no longer contain spaces. Not that it could ever work reliably.

Spotted by Ulrich Müller.

Bug: https://bugs.gentoo.org/638148
---
 pym/portage/manifest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 4ec20515e..4bca61e86 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -30,7 +30,7 @@ from portage.const import (MANIFEST2_HASH_DEFAULTS, MANIFEST2_IDENTIFIERS)
 from portage.localization import _
 
 _manifest_re = re.compile(
-	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (.*)( \d+( \S+ \S+)+)$',
+	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (\S+)( \d+( \S+ \S+)+)$',
 	re.UNICODE)
 
 if sys.hexversion >= 0x3000000:
-- 
2.15.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] portage.manifest: Fix mis-parsing Manifests with numerical checksums
  2017-11-19 17:12 [gentoo-portage-dev] [PATCH] portage.manifest: Fix mis-parsing Manifests with numerical checksums Michał Górny
@ 2017-11-19 23:10 ` Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2017-11-19 23:10 UTC (permalink / raw
  To: gentoo-portage-dev, Michał Górny

On 11/19/2017 09:12 AM, Michał Górny wrote:
> Fix the regular expression used to parse Manifests not to fail horribly
> when one of the checksums accidentally happens to be all-digits.
> 
> The previously used regular expression used to greedily take everything
> up to the first number as filename. If one of the checksums happened to
> be purely numeric, this meant that everything up to that checksum was
> taken as filename, and the checksum itself was taken as file size. It
> was also capable of accepting an empty filename.
> 
> The updated regular expression uses '\S+' to match filenames. Therefore,
> the match is terminated on first whitespace character and filenames can
> no longer contain spaces. Not that it could ever work reliably.
> 
> Spotted by Ulrich Müller.
> 
> Bug: https://bugs.gentoo.org/638148
> ---
>  pym/portage/manifest.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
> index 4ec20515e..4bca61e86 100644
> --- a/pym/portage/manifest.py
> +++ b/pym/portage/manifest.py
> @@ -30,7 +30,7 @@ from portage.const import (MANIFEST2_HASH_DEFAULTS, MANIFEST2_IDENTIFIERS)
>  from portage.localization import _
>  
>  _manifest_re = re.compile(
> -	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (.*)( \d+( \S+ \S+)+)$',
> +	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (\S+)( \d+( \S+ \S+)+)$',
>  	re.UNICODE)
>  
>  if sys.hexversion >= 0x3000000:
> 

Looks good, please merge.
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-19 23:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 17:12 [gentoo-portage-dev] [PATCH] portage.manifest: Fix mis-parsing Manifests with numerical checksums Michał Górny
2017-11-19 23:10 ` Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox