Exploit database

GH-13794a28e99af8452ce8e4224a1bc216

trinadh465/frameworks_base_aosp10_r33_cve-2022-20138

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2022-20138

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files5

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

services/backup/java/com/android/server/backup/encryption/chunk/Chunk.java

Java · 1,709 bytes
package com.android.server.backup.encryption.chunk;

import android.util.proto.ProtoInputStream;

import java.io.IOException;

/**
 * Information about a chunk entry in a protobuf. Only used for reading from a {@link
 * ProtoInputStream}.
 */
public class Chunk {
    /**
     * Reads a Chunk from a {@link ProtoInputStream}. Expects the message to be of format {@link
     * ChunksMetadataProto.Chunk}.
     *
     * @param inputStream currently at a {@link ChunksMetadataProto.Chunk} message.
     * @throws IOException when the message is not structured as expected or a field can not be
     *     read.
     */
    static Chunk readFromProto(ProtoInputStream inputStream) throws IOException {
        Chunk result = new Chunk();

        while (inputStream.nextField() != ProtoInputStream.NO_MORE_FIELDS) {
            switch (inputStream.getFieldNumber()) {
                case (int) ChunksMetadataProto.Chunk.HASH:
                    result.mHash = inputStream.readBytes(ChunksMetadataProto.Chunk.HASH);
                    break;
                case (int) ChunksMetadataProto.Chunk.LENGTH:
                    result.mLength = inputStream.readInt(ChunksMetadataProto.Chunk.LENGTH);
                    break;
            }
        }

        return result;
    }

    private int mLength;
    private byte[] mHash;

    /** Private constructor. This class should only be instantiated by calling readFromProto. */
    private Chunk() {
        // Set default values for fields in case they are not available in the proto.
        mHash = new byte[]{};
        mLength = 0;
    }

    public int getLength() {
        return mLength;
    }

    public byte[] getHash() {
        return mHash;
    }
}