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

Unverified Commit 91a4e5ad authored by Marco Nelissen's avatar Marco Nelissen Committed by Michael Bestas
Browse files

Correctly handle dup() failure in Parcel::readNativeHandle

bail out if dup() fails, instead of creating an invalid native_handle_t

Bug: 28395952

Change-Id: Ia1a6198c0f45165b9c6a55a803e5f64d8afa0572
(cherry picked from commit 1de7966c)
parent 1d11b3dd
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -1150,7 +1150,13 @@ native_handle* Parcel::readNativeHandle() const


    for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
    for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
        h->data[i] = dup(readFileDescriptor());
        h->data[i] = dup(readFileDescriptor());
        if (h->data[i] < 0) err = BAD_VALUE;
        if (h->data[i] < 0) {
            for (int j = 0; j < i; j++) {
                close(h->data[j]);
            }
            native_handle_delete(h);
            return 0;
        }
    }
    }
    err = read(h->data + numFds, sizeof(int)*numInts);
    err = read(h->data + numFds, sizeof(int)*numInts);
    if (err != NO_ERROR) {
    if (err != NO_ERROR) {