Init the string value and add protection for WelsStrcat()
This commit is contained in:
@@ -79,7 +79,7 @@ typedef struct TagWelsTime {
|
|||||||
|
|
||||||
int32_t WelsSnprintf (char* buffer, int32_t sizeOfBuffer, const char* format, ...);
|
int32_t WelsSnprintf (char* buffer, int32_t sizeOfBuffer, const char* format, ...);
|
||||||
char* WelsStrncpy (char* dest, int32_t sizeInBytes, const char* src);
|
char* WelsStrncpy (char* dest, int32_t sizeInBytes, const char* src);
|
||||||
char* WelsStrcat (char* dest, int32_t sizeInBytes, const char* src);
|
char* WelsStrcat (char* dest, uint32_t sizeInBytes, const char* src);
|
||||||
int32_t WelsVsnprintf (char* buffer, int32_t sizeOfBuffer, const char* format, va_list argptr);
|
int32_t WelsVsnprintf (char* buffer, int32_t sizeOfBuffer, const char* format, va_list argptr);
|
||||||
|
|
||||||
WelsFileHandle* WelsFopen (const char* filename, const char* mode);
|
WelsFileHandle* WelsFopen (const char* filename, const char* mode);
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ int32_t WelsSnprintf (char* pBuffer, int32_t iSizeOfBuffer, const char* kpForma
|
|||||||
return iRc;
|
return iRc;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* WelsStrncpy (char* pDest, int32_t iSizeInBytes, const char* kpSrc) {
|
char* WelsStrncpy (char* pDest, uint32_t uiSizeInBytes, const char* kpSrc) {
|
||||||
strncpy_s (pDest, iSizeInBytes, kpSrc, _TRUNCATE);
|
strncpy_s (pDest, uiSizeInBytes, kpSrc, _TRUNCATE);
|
||||||
|
|
||||||
return pDest;
|
return pDest;
|
||||||
}
|
}
|
||||||
@@ -242,9 +242,11 @@ int32_t WelsStrftime (char* pBuffer, int32_t iSize, const char* kpFormat, const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
char* WelsStrcat (char* pDest, int32_t iSizeInBytes, const char* kpSrc) {
|
char* WelsStrcat (char* pDest, uint32_t uiSizeInBytes, const char* kpSrc) {
|
||||||
int32_t iCurLen = (int32_t)strlen (pDest);
|
uint32_t uiCurLen = strlen (pDest);
|
||||||
return WelsStrncpy (pDest + iCurLen, iSizeInBytes - iCurLen, kpSrc);
|
if (uiSizeInBytes > uiCurLen)
|
||||||
|
return WelsStrncpy (pDest + uiCurLen, uiSizeInBytes - uiCurLen, kpSrc);
|
||||||
|
return pDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WelsFwrite (const void* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
|
int32_t WelsFwrite (const void* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ float WelsCalcPsnr (const void* kpTarPic,
|
|||||||
|
|
||||||
void WelsLog (SLogContext* logCtx, int32_t iLevel, const char* kpFmt, ...) {
|
void WelsLog (SLogContext* logCtx, int32_t iLevel, const char* kpFmt, ...) {
|
||||||
va_list vl;
|
va_list vl;
|
||||||
char pTraceTag[MAX_LOG_SIZE];
|
char pTraceTag[MAX_LOG_SIZE] = {0};
|
||||||
switch (iLevel) {
|
switch (iLevel) {
|
||||||
case WELS_LOG_ERROR:
|
case WELS_LOG_ERROR:
|
||||||
WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] this = 0x%p, Error:", logCtx->pCodecInstance);
|
WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] this = 0x%p, Error:", logCtx->pCodecInstance);
|
||||||
|
|||||||
Reference in New Issue
Block a user