summaryrefslogtreecommitdiff
path: root/XMPFiles/source/FileHandlers
diff options
context:
space:
mode:
authorsuhail95 <suhailkhan408.sk@gmail.com>2023-12-21 17:04:03 +0530
committerGitHub <noreply@github.com>2023-12-21 17:04:03 +0530
commit5f6fe44f19842ae43dedc3da3fd5d5dafb29e501 (patch)
tree91185dc41ca6a319985bf82bf7ccc7afdcbe7458 /XMPFiles/source/FileHandlers
parente0955b272ab6035b2921fa2c649aca5ecfe5ab81 (diff)
Integration for December 2023 release (#85)
Diffstat (limited to 'XMPFiles/source/FileHandlers')
-rw-r--r--XMPFiles/source/FileHandlers/AVCHD_Handler.cpp8
-rw-r--r--XMPFiles/source/FileHandlers/P2_Handler.cpp4
-rw-r--r--XMPFiles/source/FileHandlers/PostScript_Handler.cpp1
-rw-r--r--XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp21
4 files changed, 18 insertions, 16 deletions
diff --git a/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp b/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp
index 58b4b1f..48e5b26 100644
--- a/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp
+++ b/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp
@@ -1609,7 +1609,7 @@ static void AVCCAM_SetXMPStartTimecode ( SXMPMeta& xmpObj, const XMP_Uns8* avcca
if ( dmTimeFormat != NULL ) {
char timecodeBuff [12];
- sprintf ( timecodeBuff, "%d%d%c%d%d%c%d%d%c%d%d", hourTens, hourUnits, tcSeparator,
+ snprintf ( timecodeBuff, sizeof(timecodeBuff), "%d%d%c%d%d%c%d%d%c%d%d", hourTens, hourUnits, tcSeparator,
minuteTens, minuteUnits, tcSeparator, secondTens, secondUnits, tcSeparator, frameTens, frameUnits);
xmpObj.SetProperty( kXMP_NS_DM, "startTimeScale", dmTimeScale, kXMP_DeleteExisting );
@@ -1638,7 +1638,7 @@ static bool AVCHD_SetXMPMakeAndModel ( SXMPMeta& xmpObj, const AVCHD_blkClipExte
case kMakerIDPanasonic : xmpValue = "Panasonic"; break;
case kMakerIDSony : xmpValue = "Sony"; break;
default :
- std::sprintf ( hexMakeNumber, "0x%04x", clipExtData.mClipInfoExt.mMakerID );
+ snprintf ( hexMakeNumber,sizeof(hexMakeNumber), "0x%04x", clipExtData.mClipInfoExt.mMakerID );
xmpValue = hexMakeNumber;
break;
@@ -1693,7 +1693,7 @@ static bool AVCHD_SetXMPMakeAndModel ( SXMPMeta& xmpObj, const AVCHD_blkClipExte
// Panasonic has said that if we don't have a string for the model number, they'd like to see the code
// anyway. We'll do the same for every manufacturer except Sony, who have said that they use
// the same model number for multiple cameras.
- std::sprintf ( hexModelNumber, "0x%04x", clipExtData.mClipInfoExt.mMakerModelCode );
+ snprintf ( hexModelNumber,sizeof(hexModelNumber), "0x%04x", clipExtData.mClipInfoExt.mMakerModelCode );
xmpValue = hexModelNumber;
}
@@ -1800,7 +1800,7 @@ static std::string AVCHD_DateFieldToXMP ( XMP_Uns8 avchdTimeZone, const XMP_Uns8
char dateBuff [26];
- sprintf ( dateBuff,
+ snprintf ( dateBuff, sizeof(dateBuff),
"%01d%01d%01d%01d-%01d%01d-%01d%01dT%01d%01d:%01d%01d:%01d%01d%+02d:%02d",
(avchdDateTime[0] >> 4), (avchdDateTime[0] & 0x0F),
(avchdDateTime[1] >> 4), (avchdDateTime[1] & 0x0F),
diff --git a/XMPFiles/source/FileHandlers/P2_Handler.cpp b/XMPFiles/source/FileHandlers/P2_Handler.cpp
index 580fc5e..c36047b 100644
--- a/XMPFiles/source/FileHandlers/P2_Handler.cpp
+++ b/XMPFiles/source/FileHandlers/P2_Handler.cpp
@@ -852,7 +852,7 @@ void P2_MetaHandler::SetGPSPropertyFromLegacyXML ( XML_NodePtr legacyLocationCo
const double minutes = fractionalDegrees * 60.0;
char xmpValue [128];
- sprintf ( xmpValue, "%d,%.5lf%c", static_cast<int>(wholeDegrees), minutes, direction );
+ snprintf ( xmpValue, sizeof(xmpValue), "%d,%.5lf%c", static_cast<int>(wholeDegrees), minutes, direction );
this->xmpObj.SetProperty ( kXMP_NS_EXIF, propName, xmpValue );
this->containsXMP = true;
@@ -902,7 +902,7 @@ void P2_MetaHandler::SetAltitudeFromLegacyXML ( XML_NodePtr legacyLocationConte
char xmpValue [128];
- sprintf ( xmpValue, "%d/1", altitude );
+ snprintf ( xmpValue, sizeof(xmpValue), "%d/1", altitude );
this->xmpObj.SetProperty ( kXMP_NS_EXIF, "GPSAltitude", xmpValue );
this->containsXMP = true;
diff --git a/XMPFiles/source/FileHandlers/PostScript_Handler.cpp b/XMPFiles/source/FileHandlers/PostScript_Handler.cpp
index bc55dfa..c13529a 100644
--- a/XMPFiles/source/FileHandlers/PostScript_Handler.cpp
+++ b/XMPFiles/source/FileHandlers/PostScript_Handler.cpp
@@ -885,6 +885,7 @@ void PostScript_MetaHandler::ParsePSFile()
if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 ))
{
ioBuf.ptr+=4;
+ if ( !CheckFileSpace( fileRef, &ioBuf, 1 ) ) return;
while ( !IsNewline( *ioBuf.ptr ) )
{
if ( !CheckFileSpace( fileRef, &ioBuf, 1 ) ) return;
diff --git a/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp b/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp
index e4a7162..f8852f9 100644
--- a/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp
+++ b/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp
@@ -6,7 +6,8 @@
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================
-
+#define BUFFER_SIZE 255
+#define TIMECODE_SIZE 256
#include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header.
#include "public/include/XMP_Const.h"
@@ -290,7 +291,7 @@ static bool ReadIDXFile ( const std::string& idxPath,
idxFile.ReadAll ( &hdvFileBlock.mTotalFrame, 4 );
// Compose file name we expect from file contents and break out on match.
- sprintf ( filenameBuffer, "%02d-%02d-%02d_%02d%02d%02d",
+ snprintf ( filenameBuffer, sizeof(filenameBuffer), "%02d-%02d-%02d_%02d%02d%02d",
hdvFileBlock.mFileNameYear + 2000,
hdvFileBlock.mFileNameMonth,
hdvFileBlock.mFileNameDay,
@@ -377,16 +378,16 @@ static bool ReadIDXFile ( const std::string& idxPath,
// Sample size and scale.
if ( clipSampleScale != 0 ) {
- char buffer[255];
+ char buffer[BUFFER_SIZE];
if ( digestFound || (! xmpObj->DoesPropertyExist ( kXMP_NS_DM, "startTimeScale" )) ) {
- sprintf(buffer, "%d", clipSampleScale);
+ snprintf(buffer,BUFFER_SIZE, "%d", clipSampleScale);
xmpValue = buffer;
xmpObj->SetProperty ( kXMP_NS_DM, "startTimeScale", xmpValue, kXMP_DeleteExisting );
}
if ( digestFound || (! xmpObj->DoesPropertyExist ( kXMP_NS_DM, "startTimeSampleSize" )) ) {
- sprintf(buffer, "%d", clipSampleSize);
+ snprintf(buffer,BUFFER_SIZE, "%d", clipSampleSize);
xmpValue = buffer;
xmpObj->SetProperty ( kXMP_NS_DM, "startTimeSampleSize", xmpValue, kXMP_DeleteExisting );
}
@@ -396,11 +397,11 @@ static bool ReadIDXFile ( const std::string& idxPath,
const int frameCount = (hdvFileBlock.mTotalFrame[0] << 24) + (hdvFileBlock.mTotalFrame[1] << 16) +
(hdvFileBlock.mTotalFrame[2] << 8) + hdvFileBlock.mTotalFrame[3];
- sprintf ( buffer, "%d", frameCount );
+ snprintf ( buffer,BUFFER_SIZE, "%d", frameCount );
xmpValue = buffer;
xmpObj->SetStructField ( kXMP_NS_DM, "duration", kXMP_NS_DM, "value", xmpValue, 0 );
- sprintf ( buffer, "%d/%d", clipSampleSize, clipSampleScale );
+ snprintf ( buffer,BUFFER_SIZE, "%d/%d", clipSampleSize, clipSampleScale );
xmpValue = buffer;
xmpObj->SetStructField ( kXMP_NS_DM, "duration", kXMP_NS_DM, "scale", xmpValue, 0 );
@@ -421,8 +422,8 @@ static bool ReadIDXFile ( const std::string& idxPath,
const int tcHours = ExtractTimeCodeByte ( hdvFileBlock.mStartTimeCode[3], 0x30 );
// HH:MM:SS:FF or HH;MM;SS;FF
- char timecode[256];
- sprintf ( timecode, "%02d%c%02d%c%02d%c%02d", tcHours, chDF, tcMinutes, chDF, tcSeconds, chDF, tcFrames );
+ char timecode[TIMECODE_SIZE];
+ snprintf ( timecode,TIMECODE_SIZE, "%02d%c%02d%c%02d%c%02d", tcHours, chDF, tcMinutes, chDF, tcSeconds, chDF, tcFrames );
std::string sonyTimeString = timecode;
xmpObj->GetStructField ( kXMP_NS_DM, "startTimecode", kXMP_NS_DM, "timeValue", &xmpString, 0 );
@@ -476,7 +477,7 @@ static bool ReadIDXFile ( const std::string& idxPath,
// YYYY-MM-DDThh:mm:ssZ
char date[256];
- sprintf ( date, "%4d-%02d-%02dT%02d:%02d:%02dZ",
+ snprintf ( date,sizeof(date), "%4d-%02d-%02dT%02d:%02d:%02dZ",
hdvFileBlock.mFileNameYear + 2000,
hdvFileBlock.mFileNameMonth,
hdvFileBlock.mFileNameDay,