Skip Menu |

This queue is for tickets about the XS-Parse-Sublike CPAN distribution.

Report information
The Basics
Id: 133035
Status: new
Priority: 0/
Queue: XS-Parse-Sublike

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.10
Fixed in: (no value)



Subject: A possible integer overlflow in a croak() argument
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} An attached patch fixes it.
Subject: 0001-Fix-type-mismatch-in-croak-format-string-width-argum.patch
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