[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1085179: debcheck: Wrongly parse build profile restrictions with several terms



Package: qa.debian.org
Severity: normal
Tags: patch
User: qa.debian.org@packages.debian.org
Usertags: debcheck

Hello,

While checking my newly uploaded nxt-python package, I found that
debcheck does not parse correctly build profile restrictions with
several terms.

Example of Build-Depends that fail to parse:

	python3-usb <!nocheck> <!nodoc>

The current code use ungreedy matching, but anchored to the end of the
string, so the result is actually greedy:

	/\s*(\<)\s*(.*?)\s*\>$/xp
	                 ^^

And in the above example, it matches "!nocheck> <!nodoc".

See also: https://wiki.debian.org/BuildProfileSpec

Previous bug about this (partial fix):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=816448

I have made a patch to fix this, you can find it as attachment, or on

https://git.ni.fr.eu.org/nicolas/debian/qa.git/ fix-build-profile

Regards,

Nicolas.
>From f6832d5570d7e0b9266ba2139cd629194d5fa77e Mon Sep 17 00:00:00 2001
From: Nicolas Schodet <nico@ni.fr.eu.org>
Date: Tue, 15 Oct 2024 21:51:25 +0200
Subject: [PATCH] Fix parsing of build profile constrains with several terms

Example of Build-Depends that failed to parse:

	python3-usb <!nocheck> <!nodoc>

The previous code use ungreedy matching, but anchored to the end of
the string, so the result is actually greedy:

	/\s*(\<)\s*(.*?)\s*\>$/xp
	             ^^

And in the above example, it matched "!nocheck> <!nodoc".

Fixed code explicitly excludes the delimiter.
---
 data/debcheck/debcheck | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/data/debcheck/debcheck b/data/debcheck/debcheck
index efe6b364..7bab4013 100755
--- a/data/debcheck/debcheck
+++ b/data/debcheck/debcheck
@@ -541,8 +541,8 @@ sub checkBuildDepends($$$) {
 						my $depends_archs = undef;
 
 						my $partdependencyclean = $partdependency;
-						while ($partdependencyclean =~ /\s*(\[)\s*(.*?)\s*\]$/xp
-								or $partdependencyclean =~ /\s*(\<)\s*(.*?)\s*\>$/xp) {
+						while ($partdependencyclean =~ /\s*(\[)\s*([^]]*)\s*\]$/xp
+								or $partdependencyclean =~ /\s*(\<)\s*([^>]*)\s*\>$/xp) {
 							my $item = $2;
 							$partdependencyclean = ${^PREMATCH};
 
-- 
2.39.5


Reply to: