From 1cdd814e1bba2e4c95032972de37f13532bcc5e9 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Tue, 20 Nov 2018 14:42:39 +0100 Subject: [PATCH] Fix coverity issues --- rtengine/lcp.cc | 7 ++++--- rtengine/lcp.h | 4 ++-- rtengine/lj92.c | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 94be05ac2..34ad7a545 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -760,12 +760,13 @@ void XMLCALL rtengine::LCPProfile::XmlStartHandler(void* pLCPProfile, const char ++src; } - strcpy(pProf->lastTag, src); - + strncpy(pProf->lastTag, src, sizeof(pProf->lastTag) - 1); + pProf->lastTag[sizeof(pProf->lastTag) - 1] = 0; const std::string src_str = src; if (src_str == "VignetteModelPiecewiseParam") { - strcpy(pProf->inInvalidTag, src); + strncpy(pProf->inInvalidTag, src, sizeof(pProf->inInvalidTag) - 1); + pProf->inInvalidTag[sizeof(pProf->inInvalidTag) - 1] = 0; } if (src_str == "CameraProfiles") { diff --git a/rtengine/lcp.h b/rtengine/lcp.h index b50fd335e..d588ac381 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -131,8 +131,8 @@ private: bool inPerspect; bool inAlternateLensID; bool inAlternateLensNames; - char lastTag[256]; - char inInvalidTag[256]; + char lastTag[257]; + char inInvalidTag[257]; LCPPersModel* pCurPersModel; LCPModelCommon* pCurCommon; diff --git a/rtengine/lj92.c b/rtengine/lj92.c index cfdae6bf9..c4f1cc15c 100644 --- a/rtengine/lj92.c +++ b/rtengine/lj92.c @@ -89,7 +89,7 @@ static int parseHuff(ljp* self) { u8* huffhead = &self->data[self->ix]; // xstruct.unpack('>HB16B',self.data[self.ix:self.ix+19]) u8* bits = &huffhead[2]; bits[0] = 0; // Because table starts from 1 - int hufflen = BEH(huffhead[0]); + unsigned int hufflen = BEH(huffhead[0]); if ((self->ix + hufflen) >= self->datalen) return ret; #ifdef SLOW_HUFF u8* huffval = calloc(hufflen - 19,sizeof(u8)); @@ -546,8 +546,10 @@ static int parseScan(ljp* self) { Px = left + lastrow[col] - lastrow[col-1];break; case 5: Px = left + ((lastrow[col] - lastrow[col-1])>>1);break; + /* case 6 has a shortcut above case 6: Px = lastrow[col] + ((left - lastrow[col-1])>>1);break; + */ case 7: Px = (left + lastrow[col])>>1;break; }