Skip to content

Commit fb910e8

Browse files
James DongAndroid (Google) Code Review
authored andcommitted
Merge "Fixed a buffer overflow issue" into jb-dev
2 parents 01bf82f + 54c40e0 commit fb910e8

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)