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