Reviewed in bug #1859576.
This commit is contained in:
Petr Písař 2020-07-27 15:46:26 +02:00
parent 581d44acc7
commit f96aed6e0b
4 changed files with 133 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/XS-Parse-Sublike-0.10.tar.gz

View File

@ -0,0 +1,59 @@
From 4ed0f17a2b5187a7b18ce6720d717c453f4316d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 22 Jul 2020 15:23:07 +0200
Subject: [PATCH] Fix type mismatch in croak format string width argument
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC 10 reports on a x86_64 Linux platform:
lib/XS/Parse/Sublike.xs: In function 'IMPL_xs_parse_sublike_any':
lib/XS/Parse/Sublike.xs:320:13: warning: field precision specifier '.*' expects argument of type 'int', but argument 2 has type 'STRLEN' {aka 'long unsigned int'} [-Wformat=]
320 | croak("Expected a keyword to introduce a sub or sub-like construction, found \"%.*s\"",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321 | kwlen, kw);
| ~~~~~
| |
| STRLEN {aka long unsigned int}
This patch fixes it.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
lib/XS/Parse/Sublike.xs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/XS/Parse/Sublike.xs b/lib/XS/Parse/Sublike.xs
index 03bc327..478d08a 100644
--- a/lib/XS/Parse/Sublike.xs
+++ b/lib/XS/Parse/Sublike.xs
@@ -9,6 +9,7 @@
#include "XSUB.h"
#include "XSParseSublike.h"
+#include <limits.h>
#define HAVE_PERL_VERSION(R, V, S) \
(PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
@@ -316,9 +317,14 @@ static int IMPL_xs_parse_sublike_any(pTHX_ const struct XSParseSublikeHooks *hoo
/* We permit 'sub' as a NULL set of hooks; anything else should be a registered keyword */
if(kwlen != 3 || !strEQ(kw, "sub")) {
reg = find_permitted(aTHX_ kw, kwlen);
- if(!reg)
- croak("Expected a keyword to introduce a sub or sub-like construction, found \"%.*s\"",
- kwlen, kw);
+ if(!reg) {
+ if(kwlen <= INT_MAX)
+ croak("Expected a keyword to introduce a sub or sub-like construction, found \"%.*s\"",
+ (int)kwlen, kw);
+ else
+ croak("Expected a keyword to introduce a sub or sub-like construction, found \"%.*s...\"",
+ INT_MAX, kw);
+ }
}
SvREFCNT_dec(kwsv);
--
2.25.4

View File

@ -0,0 +1,72 @@
# Perform optional tests
%bcond_without perl_XS_Parse_Sublike_enables_optional_tests
Name: perl-XS-Parse-Sublike
Version: 0.10
Release: 1%{?dist}
Summary: XS functions to assist in parsing sub-like syntax
License: GPL+ or Artistic
URL: https://metacpan.org/release/XS-Parse-Sublike
Source0: https://cpan.metacpan.org/authors/id/P/PE/PEVANS/XS-Parse-Sublike-%{version}.tar.gz
# Fix an integer overflow in croak(), CPAN RT#133035
Patch0: XS-Parse-Sublike-0.10-Fix-type-mismatch-in-croak-format-string-width-argum.patch
BuildRequires: coreutils
BuildRequires: findutils
BuildRequires: perl-devel
BuildRequires: perl-generators
BuildRequires: perl-interpreter
BuildRequires: perl(:VERSION) >= 5.16
BuildRequires: perl(base)
BuildRequires: perl(ExtUtils::CBuilder)
BuildRequires: perl(lib)
BuildRequires: perl(Module::Build)
BuildRequires: perl(strict)
BuildRequires: perl(warnings)
# Run-time:
BuildRequires: perl(XSLoader)
# Tests:
BuildRequires: perl(B::Deparse)
BuildRequires: perl(feature)
BuildRequires: perl(Test::Fatal)
BuildRequires: perl(Test::More) >= 0.88
%if %{with perl_XS_Parse_Sublike_enables_optional_tests}
# Optional tests:
BuildRequires: perl(Test::Pod) >= 1
%endif
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%description
This module provides some XS functions to assist in writing parsers for
sub-like syntax, primarily for authors of keyword plugins using the
PL_keyword_plugin hook mechanism.
%prep
%setup -q -n XS-Parse-Sublike-%{version}
%patch0 -p1
%if !%{with perl_XS_Parse_Sublike_enables_optional_tests}
rm t/99pod.t
perl -i -ne 'print $_ unless m{^t/99pod\.t}' MANIFEST
%endif
%build
perl Build.PL --installdirs=vendor --optimize="$RPM_OPT_FLAGS"
./Build
%install
./Build install --destdir=$RPM_BUILD_ROOT --create_packlist=0
find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -delete
%{_fixperms} $RPM_BUILD_ROOT/*
%check
./Build test
%files
%license LICENSE
%doc Changes README
%{perl_vendorarch}/auto/*
%{perl_vendorarch}/XS*
%{_mandir}/man3/*
%changelog
* Wed Jul 22 2020 Petr Pisar <ppisar@redhat.com> 0.10-1
- Specfile autogenerated by cpanspec 1.78.

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (XS-Parse-Sublike-0.10.tar.gz) = 311f5fa5602d7243dda70470937f0e9e42acc66d46a5c94f1cf61ed9a632d2c43363c6b797194457518cd6af552f65a96889022e9769cc66ef3d1bef9455d3da