Skip to content

Commit

Permalink
added safety check on CENC sai size
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Dec 6, 2023
1 parent 666daf2 commit fe6bb7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/filters/mux_isom.c
Original file line number Diff line number Diff line change
Expand Up @@ -4538,7 +4538,10 @@ static GF_Err mp4_mux_cenc_update(GF_MP4MuxCtx *ctx, TrackWriter *tkw, GF_Filter
}
}

if (act_type==CENC_ADD_FRAG) {
if (pck_is_encrypted && (sai_size>255)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MP4Mux] CENC SAI size %u larger than max allowed size (255) in ISOBMFF - please reencode content\n", sai_size ));
e = GF_NOT_SUPPORTED;
} else if (act_type==CENC_ADD_FRAG) {
#ifndef GPAC_DISABLE_ISOM_FRAGMENTS
if (pck_is_encrypted) {
e = gf_isom_fragment_set_cenc_sai(ctx->file, tkw->track_id, sai, sai_size, tkw->cenc_subsamples, ctx->saio32, tkw->cenc_multikey);
Expand Down
5 changes: 4 additions & 1 deletion src/isomedia/box_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -5951,7 +5951,7 @@ GF_Err senc_box_dump(GF_Box *a, FILE * trace)
}
}
if (use_multikey || ((ptr->flags & 0x2) && (sai->cenc_data_size>iv_size)) ) {
u32 j, nb_subs;
u32 j, nb_subs, total_bytes=0;

nb_subs = gf_bs_read_int(bs, subs_bits);
gf_fprintf(trace, " SubsampleCount=\"%u\"", nb_subs);
Expand All @@ -5967,7 +5967,10 @@ GF_Err senc_box_dump(GF_Box *a, FILE * trace)
clear = gf_bs_read_u16(bs);
crypt = gf_bs_read_u32(bs);
gf_fprintf(trace, " NumClearBytes=\"%u\" NumEncryptedBytes=\"%u\"/>\n", clear, crypt);
total_bytes+=clear+crypt;
}
if (!gf_sys_is_test_mode())
gf_fprintf(trace, "<!-- counted %u bytes for entry -->\n", total_bytes);
} else {
gf_fprintf(trace, ">\n");
}
Expand Down

0 comments on commit fe6bb7b

Please sign in to comment.