Loading libs/binder/ndk/include_cpp/android/binder_parcel_utils.h +29 −17 Original line number Diff line number Diff line Loading @@ -550,8 +550,8 @@ binder_status_t AParcel_writeNullableStdVectorParcelableElement(AParcel* parcel, const void* vectorData, size_t index) { const std::optional<std::vector<P>>* vector = static_cast<const std::optional<std::vector<P>*>>(vectorData); return AParcel_writeNullableParcelable(parcel, vector->at(index)); static_cast<const std::optional<std::vector<P>>*>(vectorData); return AParcel_writeNullableParcelable(parcel, (*vector)->at(index)); } /** Loading @@ -561,7 +561,7 @@ template <typename P> binder_status_t AParcel_readNullableStdVectorParcelableElement(const AParcel* parcel, void* vectorData, size_t index) { std::optional<std::vector<P>>* vector = static_cast<std::optional<std::vector<P>>*>(vectorData); return AParcel_readNullableParcelable(parcel, &vector->at(index)); return AParcel_readNullableParcelable(parcel, &(*vector)->at(index)); } /** Loading @@ -573,11 +573,7 @@ inline binder_status_t AParcel_writeStdVectorParcelableElement<ScopedFileDescrip AParcel* parcel, const void* vectorData, size_t index) { const std::vector<ScopedFileDescriptor>* vector = static_cast<const std::vector<ScopedFileDescriptor>*>(vectorData); int writeFd = vector->at(index).get(); if (writeFd < 0) { return STATUS_UNEXPECTED_NULL; } return AParcel_writeParcelFileDescriptor(parcel, writeFd); return AParcel_writeRequiredParcelFileDescriptor(parcel, vector->at(index)); } /** Loading @@ -589,15 +585,31 @@ inline binder_status_t AParcel_readStdVectorParcelableElement<ScopedFileDescript const AParcel* parcel, void* vectorData, size_t index) { std::vector<ScopedFileDescriptor>* vector = static_cast<std::vector<ScopedFileDescriptor>*>(vectorData); int readFd; binder_status_t status = AParcel_readParcelFileDescriptor(parcel, &readFd); if (status == STATUS_OK) { if (readFd < 0) { return STATUS_UNEXPECTED_NULL; return AParcel_readRequiredParcelFileDescriptor(parcel, &vector->at(index)); } vector->at(index).set(readFd); /** * Writes a ScopedFileDescriptor object inside a std::optional<std::vector<ScopedFileDescriptor>> at * index 'index' to 'parcel'. */ template <> inline binder_status_t AParcel_writeNullableStdVectorParcelableElement<ScopedFileDescriptor>( AParcel* parcel, const void* vectorData, size_t index) { const std::optional<std::vector<ScopedFileDescriptor>>* vector = static_cast<const std::optional<std::vector<ScopedFileDescriptor>>*>(vectorData); return AParcel_writeNullableParcelFileDescriptor(parcel, (*vector)->at(index)); } return status; /** * Reads a ScopedFileDescriptor object inside a std::optional<std::vector<ScopedFileDescriptor>> at * index 'index' from 'parcel'. */ template <> inline binder_status_t AParcel_readNullableStdVectorParcelableElement<ScopedFileDescriptor>( const AParcel* parcel, void* vectorData, size_t index) { std::optional<std::vector<ScopedFileDescriptor>>* vector = static_cast<std::optional<std::vector<ScopedFileDescriptor>>*>(vectorData); return AParcel_readNullableParcelFileDescriptor(parcel, &(*vector)->at(index)); } /** Loading libs/binder/tests/parcel_fuzzer/binder_ndk.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -95,8 +95,11 @@ std::vector<ParcelRead<NdkParcelAdapter>> BINDER_NDK_PARCEL_READ_FUNCTIONS{ PARCEL_READ(std::vector<std::string>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<std::optional<std::string>>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<SomeParcelable>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<std::optional<SomeParcelable>>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<ndk::SpAIBinder>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<ndk::SpAIBinder>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<ndk::ScopedFileDescriptor>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<ndk::ScopedFileDescriptor>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<int32_t>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<int32_t>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<uint32_t>, ndk::AParcel_readVector), Loading Loading
libs/binder/ndk/include_cpp/android/binder_parcel_utils.h +29 −17 Original line number Diff line number Diff line Loading @@ -550,8 +550,8 @@ binder_status_t AParcel_writeNullableStdVectorParcelableElement(AParcel* parcel, const void* vectorData, size_t index) { const std::optional<std::vector<P>>* vector = static_cast<const std::optional<std::vector<P>*>>(vectorData); return AParcel_writeNullableParcelable(parcel, vector->at(index)); static_cast<const std::optional<std::vector<P>>*>(vectorData); return AParcel_writeNullableParcelable(parcel, (*vector)->at(index)); } /** Loading @@ -561,7 +561,7 @@ template <typename P> binder_status_t AParcel_readNullableStdVectorParcelableElement(const AParcel* parcel, void* vectorData, size_t index) { std::optional<std::vector<P>>* vector = static_cast<std::optional<std::vector<P>>*>(vectorData); return AParcel_readNullableParcelable(parcel, &vector->at(index)); return AParcel_readNullableParcelable(parcel, &(*vector)->at(index)); } /** Loading @@ -573,11 +573,7 @@ inline binder_status_t AParcel_writeStdVectorParcelableElement<ScopedFileDescrip AParcel* parcel, const void* vectorData, size_t index) { const std::vector<ScopedFileDescriptor>* vector = static_cast<const std::vector<ScopedFileDescriptor>*>(vectorData); int writeFd = vector->at(index).get(); if (writeFd < 0) { return STATUS_UNEXPECTED_NULL; } return AParcel_writeParcelFileDescriptor(parcel, writeFd); return AParcel_writeRequiredParcelFileDescriptor(parcel, vector->at(index)); } /** Loading @@ -589,15 +585,31 @@ inline binder_status_t AParcel_readStdVectorParcelableElement<ScopedFileDescript const AParcel* parcel, void* vectorData, size_t index) { std::vector<ScopedFileDescriptor>* vector = static_cast<std::vector<ScopedFileDescriptor>*>(vectorData); int readFd; binder_status_t status = AParcel_readParcelFileDescriptor(parcel, &readFd); if (status == STATUS_OK) { if (readFd < 0) { return STATUS_UNEXPECTED_NULL; return AParcel_readRequiredParcelFileDescriptor(parcel, &vector->at(index)); } vector->at(index).set(readFd); /** * Writes a ScopedFileDescriptor object inside a std::optional<std::vector<ScopedFileDescriptor>> at * index 'index' to 'parcel'. */ template <> inline binder_status_t AParcel_writeNullableStdVectorParcelableElement<ScopedFileDescriptor>( AParcel* parcel, const void* vectorData, size_t index) { const std::optional<std::vector<ScopedFileDescriptor>>* vector = static_cast<const std::optional<std::vector<ScopedFileDescriptor>>*>(vectorData); return AParcel_writeNullableParcelFileDescriptor(parcel, (*vector)->at(index)); } return status; /** * Reads a ScopedFileDescriptor object inside a std::optional<std::vector<ScopedFileDescriptor>> at * index 'index' from 'parcel'. */ template <> inline binder_status_t AParcel_readNullableStdVectorParcelableElement<ScopedFileDescriptor>( const AParcel* parcel, void* vectorData, size_t index) { std::optional<std::vector<ScopedFileDescriptor>>* vector = static_cast<std::optional<std::vector<ScopedFileDescriptor>>*>(vectorData); return AParcel_readNullableParcelFileDescriptor(parcel, &(*vector)->at(index)); } /** Loading
libs/binder/tests/parcel_fuzzer/binder_ndk.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -95,8 +95,11 @@ std::vector<ParcelRead<NdkParcelAdapter>> BINDER_NDK_PARCEL_READ_FUNCTIONS{ PARCEL_READ(std::vector<std::string>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<std::optional<std::string>>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<SomeParcelable>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<std::optional<SomeParcelable>>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<ndk::SpAIBinder>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<ndk::SpAIBinder>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<ndk::ScopedFileDescriptor>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<ndk::ScopedFileDescriptor>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<int32_t>, ndk::AParcel_readVector), PARCEL_READ(std::optional<std::vector<int32_t>>, ndk::AParcel_readVector), PARCEL_READ(std::vector<uint32_t>, ndk::AParcel_readVector), Loading