Skip to content

Commit 54c40e0

Browse files
author
James Dong
committed
Fixed a buffer overflow issue
The allocated array has one byte less than the required length. Allocating the size one byte larger fixes the issue. contribution was originally from teng.hong@nxp.com Change-Id: I3aa2e6b995fd18e30649a34f201646082aab44ee related-to-bug: 6347465
1 parent 817a243 commit 54c40e0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

media/jni/mediaeditor/VideoEditorMain.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,16 +2623,21 @@ videoEditor_init(
26232623
M4OSA_Char* tmpString =
26242624
(M4OSA_Char *)videoEditJava_getString(&initialized, pEnv, tempPath,
26252625
NULL, M4OSA_NULL);
2626+
M4OSA_UInt32 length = strlen((const char *)tmpString);
2627+
// Malloc additional 2 bytes for beginning and tail separator.
2628+
M4OSA_UInt32 pathLength = length + 2;
2629+
26262630
pContext->initParams.pTempPath = (M4OSA_Char *)
2627-
M4OSA_32bitAlignedMalloc(strlen((const char *)tmpString) + 1, 0x0,
2628-
(M4OSA_Char *)"tempPath");
2631+
M4OSA_32bitAlignedMalloc(pathLength, 0x0, (M4OSA_Char *)"tempPath");
2632+
26292633
//initialize the first char. so that strcat works.
26302634
M4OSA_Char *ptmpChar = (M4OSA_Char*)pContext->initParams.pTempPath;
26312635
ptmpChar[0] = 0x00;
26322636
strncat((char *)pContext->initParams.pTempPath, (const char *)tmpString,
2633-
(size_t)strlen((const char *)tmpString));
2637+
length);
26342638
strncat((char *)pContext->initParams.pTempPath, (const char *)"/", (size_t)1);
26352639
free(tmpString);
2640+
tmpString = NULL;
26362641
pContext->mIsUpdateOverlay = false;
26372642
pContext->mOverlayFileName = NULL;
26382643
pContext->decoders = NULL;

0 commit comments

Comments
 (0)