diff options
author | Andreas Zelend <ace20022@xbmc.org> | 2016-04-05 21:08:01 +0200 |
---|---|---|
committer | Andreas Zelend <ace20022@xbmc.org> | 2016-04-05 21:08:01 +0200 |
commit | 6368510ee794279f77acedac95a0e167959bfcd4 (patch) | |
tree | 538dcffbf3f7ea682d46f6bd12d39981e6d75db6 /lib | |
parent | b1e6f6371bda3d14829cf2540fe3ce411455a755 (diff) | |
parent | a22adefd4f41abf46aa9917d3606a02913a6479f (diff) |
Merge pull request #9512 from ace20022/win_cov
[coverity] Some cleanup/fixes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/addons/library.kodi.audioengine/libKODI_audioengine.cpp | 2 | ||||
-rw-r--r-- | lib/addons/library.kodi.guilib/libKODI_guilib.cpp | 23 | ||||
-rwxr-xr-x | lib/libexif/ExifParse.cpp | 72 | ||||
-rw-r--r-- | lib/libexif/JpegParse.cpp | 9 | ||||
-rw-r--r-- | lib/libexif/libexif.h | 6 |
5 files changed, 69 insertions, 43 deletions
diff --git a/lib/addons/library.kodi.audioengine/libKODI_audioengine.cpp b/lib/addons/library.kodi.audioengine/libKODI_audioengine.cpp index 0886bd6de3..086332c01a 100644 --- a/lib/addons/library.kodi.audioengine/libKODI_audioengine.cpp +++ b/lib/addons/library.kodi.audioengine/libKODI_audioengine.cpp @@ -63,7 +63,7 @@ DLLEXPORT void AudioEngine_unregister_me(void *hdl, void* cb) // --------------------------------------------- // CAddonAEStream implementations // --------------------------------------------- -DLLEXPORT CAddonAEStream* AudioEngine_make_stream(void *hdl, void *cb, AudioEngineFormat Format, unsigned int Options) +DLLEXPORT CAddonAEStream* AudioEngine_make_stream(void *hdl, void *cb, AudioEngineFormat& Format, unsigned int Options) { if (!hdl || !cb) { diff --git a/lib/addons/library.kodi.guilib/libKODI_guilib.cpp b/lib/addons/library.kodi.guilib/libKODI_guilib.cpp index 188562a8d0..1e7e841fb1 100644 --- a/lib/addons/library.kodi.guilib/libKODI_guilib.cpp +++ b/lib/addons/library.kodi.guilib/libKODI_guilib.cpp @@ -273,9 +273,13 @@ CAddonGUIWindow::CAddonGUIWindow(void *hdl, void *cb, const char *xmlFilename, c : m_Handle(hdl) , m_cb(cb) { - CBOnInit = NULL; - CBOnClick = NULL; - CBOnFocus = NULL; + CBOnInit = nullptr; + CBOnClick = nullptr; + CBOnFocus = nullptr; + CBOnAction = nullptr; + m_WindowHandle = nullptr; + m_cbhdl = nullptr; + if (hdl && cb) { m_WindowHandle = ((CB_GUILib*)m_cb)->Window_New(((AddonCB*)m_Handle)->addonData, xmlFilename, defaultSkin, forceFallback, asDialog); @@ -958,10 +962,15 @@ DLLEXPORT bool GUI_control_rendering_dirty(GUIHANDLE handle) } CAddonGUIRenderingControl::CAddonGUIRenderingControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId) - : m_Window(window) - , m_ControlId(controlId) - , m_Handle(hdl) - , m_cb(cb) + : m_Window(window) + , m_ControlId(controlId) + , m_Handle(hdl) + , m_cb(cb) + , m_cbhdl(nullptr) + , CBCreate(nullptr) + , CBRender(nullptr) + , CBStop(nullptr) + , CBDirty(nullptr) { m_RenderingHandle = ((CB_GUILib*)m_cb)->Window_GetControl_RenderAddon(((AddonCB*)m_Handle)->addonData, m_Window->m_WindowHandle, controlId); } diff --git a/lib/libexif/ExifParse.cpp b/lib/libexif/ExifParse.cpp index 1ef43260f7..0497c4e84d 100755 --- a/lib/libexif/ExifParse.cpp +++ b/lib/libexif/ExifParse.cpp @@ -121,6 +121,8 @@ static void ErrNonfatal(const char* const msg, int a1, int a2); // NOTE: Remember to change NUM_FORMATS if you define a new format #define NUM_FORMATS 12 +const unsigned int BytesPerFormat[NUM_FORMATS] = { 1,1,2,4,8,1,1,2,4,8,4,8 }; + //-------------------------------------------------------------------------- // Internationalisation string IDs. The enum order must match that in the // language file (e.g. 'language/English/strings.xml', and EXIF_PARSE_STRING_ID_BASE @@ -198,10 +200,8 @@ static void ErrNonfatal(const char* const msg, int a1, int a2) //-------------------------------------------------------------------------- CExifParse::CExifParse () : m_FocalPlaneXRes(0.0), m_FocalPlaneUnits(0.0), m_ExifImageWidth(0), m_MotorolaOrder(false), - m_DateFound(false) -{ - m_ExifInfo = NULL; -} + m_DateFound(false), m_LargestExifOffset(0), m_ExifInfo(nullptr) +{} //-------------------------------------------------------------------------- // Convert a 16 bit unsigned value from file's native byte order @@ -358,9 +358,6 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, } } - const int BytesPerFormat[] = {0,1,1,2,4,8,1,1,2,4,8,4,8}; - - for (int de=0;de<NumDirEntries;de++) { int Tag, Format, Components; @@ -372,9 +369,8 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, Format = Get16(DirEntry+2, m_MotorolaOrder); Components = Get32(DirEntry+4, m_MotorolaOrder); - if ((Format-1) >= NUM_FORMATS) + if (Format <= 0 || Format > NUM_FORMATS) { - // (-1) catches illegal zero case as unsigned underflows to positive large. ErrNonfatal("Illegal number format %d for tag %04x", Format, Tag); continue; } @@ -385,7 +381,7 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, continue; } - ByteCount = Components * BytesPerFormat[Format]; + ByteCount = Components * BytesPerFormat[Format - 1]; if (ByteCount > 4) { @@ -423,8 +419,26 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, m_ExifInfo->Description[length] = '\0'; break; } - case TAG_MAKE: strncpy(m_ExifInfo->CameraMake, (char *)ValuePtr, 32); break; - case TAG_MODEL: strncpy(m_ExifInfo->CameraModel, (char *)ValuePtr, 40); break; + case TAG_MAKE: + { + int space = sizeof(m_ExifInfo->CameraMake); + if (space > 0) + { + strncpy(m_ExifInfo->CameraMake, (char *)ValuePtr, space - 1); + m_ExifInfo->CameraMake[space] = '\0'; + } + break; + } + case TAG_MODEL: + { + int space = sizeof(m_ExifInfo->CameraModel); + if (space > 0) + { + strncpy(m_ExifInfo->CameraModel, (char *)ValuePtr, space - 1); + m_ExifInfo->CameraModel[space] = '\0'; + } + break; + } // case TAG_SOFTWARE: strncpy(m_ExifInfo->Software, ValuePtr, 5); break; case TAG_FOCALPLANEXRES: m_FocalPlaneXRes = ConvertAnyFormat(ValuePtr, Format); break; case TAG_THUMBNAIL_OFFSET: m_ExifInfo->ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format); break; @@ -435,22 +449,34 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, break; case TAG_DATETIME_ORIGINAL: - // If we get a DATETIME_ORIGINAL, we use that one. - strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, 20); - m_DateFound = true; - break; + { + int space = sizeof(m_ExifInfo->DateTime); + if (space > 0) + { + strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, space - 1); + m_ExifInfo->DateTime[space] = '\0'; + // If we get a DATETIME_ORIGINAL, we use that one. + m_DateFound = true; + } + break; + } case TAG_DATETIME_DIGITIZED: case TAG_DATETIME: + { if (m_DateFound == false) { // If we don't already have a DATETIME_ORIGINAL, use whatever // time fields we may have. - strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, 20); -// LocaliseDate(); + int space = sizeof(m_ExifInfo->DateTime); + if (space > 0) + { + strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, space - 1); + m_ExifInfo->DateTime[space] = '\0'; + } } - break; - + break; + } case TAG_USERCOMMENT: { // The UserComment allows comments without the charset limitations of ImageDescription. @@ -866,15 +892,13 @@ void CExifParse::ProcessGpsInfo( unsigned Tag = Get16(DirEntry, m_MotorolaOrder); unsigned Format = Get16(DirEntry+2, m_MotorolaOrder); unsigned Components = (unsigned)Get32(DirEntry+4, m_MotorolaOrder); - if ((Format-1) >= NUM_FORMATS) + if (Format == 0 || Format > NUM_FORMATS) { - // (-1) catches illegal zero case as unsigned underflows to positive large. ErrNonfatal("Illegal number format %d for tag %04x", Format, Tag); continue; } - const int BytesPerFormat[] = {0,1,1,2,4,8,1,1,2,4,8,4,8}; - int ComponentSize = BytesPerFormat[Format]; + unsigned ComponentSize = BytesPerFormat[Format - 1]; unsigned ByteCount = Components * ComponentSize; const unsigned char* ValuePtr; diff --git a/lib/libexif/JpegParse.cpp b/lib/libexif/JpegParse.cpp index 2602a7b12a..6545525b89 100644 --- a/lib/libexif/JpegParse.cpp +++ b/lib/libexif/JpegParse.cpp @@ -161,7 +161,7 @@ bool CJpegParse::ExtractInfo (FILE *infile) { BYTE marker = 0; for (a=0; a<7; a++) { - bytesRead = fread(&marker, 1, sizeof(BYTE), infile); + fread(&marker, 1, sizeof(BYTE), infile); if (marker != 0xFF) break; @@ -173,13 +173,6 @@ bool CJpegParse::ExtractInfo (FILE *infile) marker = 0; } - if (marker == 0xff) - { - // 0xff is legal padding, but if we get that many, something's wrong. - printf("JpgParse: too many padding bytes"); - return false; - } - // Read the length of the section. unsigned short itemlen = 0; bytesRead = fread(&itemlen, 1, sizeof(itemlen), infile); diff --git a/lib/libexif/libexif.h b/lib/libexif/libexif.h index be2d37d1a6..aa8da07553 100644 --- a/lib/libexif/libexif.h +++ b/lib/libexif/libexif.h @@ -85,9 +85,9 @@ typedef struct { #define MAX_DATE_COPIES 10 typedef struct { - char CameraMake [32]; - char CameraModel [40]; - char DateTime [20]; + char CameraMake [33]; + char CameraModel [41]; + char DateTime [21]; int Height, Width; int Orientation; int IsColor; |