From bd057347ce341ef653904618f7545d4ee6068a35 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 7 Dec 2016 10:16:33 +0100 Subject: [PATCH] Use the safer strlcpy to copy the chapter names to the mp4v2 struct. --- MP42/MP42ChapterTrack.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index d5c82e4..e4bd3c7 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -180,7 +180,7 @@ BOOL success = YES; if ((self.edited && _areChaptersEdited) || !self.muxed) { - MP4Chapter_t * fileChapters = 0; + MP4Chapter_t *fileChapters = 0; MP4Duration refTrackDuration; uint32_t chapterCount = 0; uint32_t i = 0; @@ -221,9 +221,11 @@ refTrackDuration = moovDuration; for (i = 0; i < chapterCount; i++) { - MP42TextSample *chapter = [_chapters objectAtIndex:i]; - if ([[chapter title] UTF8String]) - strcpy(fileChapters[i].title, [[chapter title] UTF8String]); + MP42TextSample *chapter = _chapters[i]; + const char *title = chapter.title.UTF8String; + if (title) { + strlcpy(fileChapters[i].title, title, MP4V2_CHAPTER_TITLE_MAX + 1); + } if (i + 1 < chapterCount && sum < refTrackDuration) { MP42TextSample * nextChapter = [_chapters objectAtIndex:i+1];