Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19ca2d24 authored by Wonsik Kim's avatar Wonsik Kim Committed by android-build-merger
Browse files

Merge \\"DO NOT MERGE stagefright: fix possible stack overflow in AVCC...

Merge \\"DO NOT MERGE stagefright: fix possible stack overflow in AVCC reassemble\\" into klp-dev am: b239e274
am: cc3c5490

Change-Id: I772fba4484975a2f28fc947e4a16296b400f5a99
parents 726010eb cc3c5490
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -484,18 +484,28 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
    // reassemble the csd data into its original form
    sp<ABuffer> csd0;
    if (msg->findBuffer("csd-0", &csd0)) {
        int csd0size = csd0->size();
        if (mime.startsWith("video/")) { // do we need to be stricter than this?
            sp<ABuffer> csd1;
            if (msg->findBuffer("csd-1", &csd1)) {
                char avcc[1024]; // that oughta be enough, right?
                size_t outsize = reassembleAVCC(csd0, csd1, avcc);
                meta->setData(kKeyAVCC, kKeyAVCC, avcc, outsize);
                Vector<char> avcc;
                int avccSize = csd0size + csd1->size() + 1024;
                if (avcc.resize(avccSize) < 0) {
                    ALOGE("error allocating avcc (size %d); abort setting avcc.", avccSize);
                } else {
                    size_t outsize = reassembleAVCC(csd0, csd1, avcc.editArray());
                    meta->setData(kKeyAVCC, kKeyAVCC, avcc.array(), outsize);
                }
            }
        } else if (mime.startsWith("audio/")) {
            int csd0size = csd0->size();
            char esds[csd0size + 31];
            reassembleESDS(csd0, esds);
            meta->setData(kKeyESDS, kKeyESDS, esds, sizeof(esds));
            Vector<char> esds;
            int esdsSize = csd0size + 31;
            if (esds.resize(esdsSize) < 0) {
                ALOGE("error allocating esds (size %d); abort setting esds.", esdsSize);
            } else {
                reassembleESDS(csd0, esds.editArray());
                meta->setData(kKeyESDS, kKeyESDS, esds.array(), esds.size());
            }
        }
    }