a4ac56
From 62e6b70574842d7f2c547d33c85c50228522f685 Mon Sep 17 00:00:00 2001
a4ac56
From: Marc-Philip <marc-philip.werner@sap.com>
a4ac56
Date: Sun, 8 Apr 2018 12:15:29 -0600
a4ac56
Subject: [PATCH] PATCH: [perl #133074] 5.26.1: some coverity fixes
a4ac56
MIME-Version: 1.0
a4ac56
Content-Type: text/plain; charset=UTF-8
a4ac56
Content-Transfer-Encoding: 8bit
a4ac56
a4ac56
we have some coverity code scans here. They have found this
a4ac56
uninilialized variable in pp.c and the integer overrun in toke.c.
a4ac56
Though it might be possible that these are false positives (no
a4ac56
reasonable control path gets there), it's good to mute the scan here to
a4ac56
see the real problems easier.
a4ac56
a4ac56
Signed-off-by: Petr Písař <ppisar@redhat.com>
a4ac56
---
a4ac56
 pp.c   | 1 +
a4ac56
 toke.c | 8 ++++----
a4ac56
 2 files changed, 5 insertions(+), 4 deletions(-)
a4ac56
a4ac56
diff --git a/pp.c b/pp.c
a4ac56
index 5524131658..d777ae4309 100644
a4ac56
--- a/pp.c
a4ac56
+++ b/pp.c
a4ac56
@@ -3727,6 +3727,7 @@ PP(pp_ucfirst)
a4ac56
     if (! slen) {   /* If empty */
a4ac56
 	need = 1; /* still need a trailing NUL */
a4ac56
 	ulen = 0;
a4ac56
+        *tmpbuf = '\0';
a4ac56
     }
a4ac56
     else if (DO_UTF8(source)) {	/* Is the source utf8? */
a4ac56
 	doing_utf8 = TRUE;
a4ac56
diff --git a/toke.c b/toke.c
a4ac56
index 3405dc6c89..fc87252bb1 100644
a4ac56
--- a/toke.c
a4ac56
+++ b/toke.c
a4ac56
@@ -9052,7 +9052,7 @@ S_pending_ident(pTHX)
a4ac56
 		HEK * const stashname = HvNAME_HEK(stash);
a4ac56
 		SV *  const sym = newSVhek(stashname);
a4ac56
                 sv_catpvs(sym, "::");
a4ac56
-                sv_catpvn_flags(sym, PL_tokenbuf+1, tokenbuf_len - 1, (UTF ? SV_CATUTF8 : SV_CATBYTES ));
a4ac56
+                sv_catpvn_flags(sym, PL_tokenbuf+1, tokenbuf_len > 0 ? tokenbuf_len - 1 : 0, (UTF ? SV_CATUTF8 : SV_CATBYTES ));
a4ac56
                 pl_yylval.opval = newSVOP(OP_CONST, 0, sym);
a4ac56
                 pl_yylval.opval->op_private = OPpCONST_ENTERED;
a4ac56
                 if (pit != '&')
a4ac56
@@ -9080,7 +9080,7 @@ S_pending_ident(pTHX)
a4ac56
         && PL_lex_state != LEX_NORMAL
a4ac56
         && !PL_lex_brackets)
a4ac56
     {
a4ac56
-        GV *const gv = gv_fetchpvn_flags(PL_tokenbuf + 1, tokenbuf_len - 1,
a4ac56
+        GV *const gv = gv_fetchpvn_flags(PL_tokenbuf + 1, tokenbuf_len > 0 ? tokenbuf_len - 1 : 0,
a4ac56
                                          ( UTF ? SVf_UTF8 : 0 ) | GV_ADDMG,
a4ac56
                                          SVt_PVAV);
a4ac56
         if ((!gv || ((PL_tokenbuf[0] == '@') ? !GvAV(gv) : !GvHV(gv)))
a4ac56
@@ -9097,11 +9097,11 @@ S_pending_ident(pTHX)
a4ac56
     /* build ops for a bareword */
a4ac56
     pl_yylval.opval = newSVOP(OP_CONST, 0,
a4ac56
 				   newSVpvn_flags(PL_tokenbuf + 1,
a4ac56
-						      tokenbuf_len - 1,
a4ac56
+                                                      tokenbuf_len > 0 ? tokenbuf_len - 1 : 0,
a4ac56
                                                       UTF ? SVf_UTF8 : 0 ));
a4ac56
     pl_yylval.opval->op_private = OPpCONST_ENTERED;
a4ac56
     if (pit != '&')
a4ac56
-	gv_fetchpvn_flags(PL_tokenbuf+1, tokenbuf_len - 1,
a4ac56
+        gv_fetchpvn_flags(PL_tokenbuf+1, tokenbuf_len > 0 ? tokenbuf_len - 1 : 0,
a4ac56
 		     (PL_in_eval ? GV_ADDMULTI : GV_ADD)
a4ac56
                      | ( UTF ? SVf_UTF8 : 0 ),
a4ac56
 		     ((PL_tokenbuf[0] == '$') ? SVt_PV
a4ac56
-- 
a4ac56
2.14.3
a4ac56