DivestOS/Patches/LineageOS-20.0/ASB-2023-10/av-04.patch

301 lines
8.9 KiB
Diff
Raw Normal View History

20.0: October ASB picks wget https://github.com/GrapheneOS/platform_packages_services_Telecomm/commit/c873988898e1b520e0e4cfda77e26ec4377a4ce9.patch -O telecomm-01.patch wget https://github.com/GrapheneOS/platform_packages_providers_MediaProvider/commit/0fb5786dbf8b462eb106df912a7f65ab240f0d6a.patch -O mediaprovider-01.patch wget https://github.com/GrapheneOS/platform_packages_modules_Wifi/commit/1a4b9ef510410a8d8c90e80352357f08c49f10c5.patch -O wifi-01.patch wget https://github.com/GrapheneOS/platform_packages_modules_Bluetooth/commit/364a1d99624e8dca6501d98166efbb8061362970.patch -O bluetooth-01.patch wget https://github.com/GrapheneOS/platform_packages_apps_Settings/commit/87a06448b96e1ccd2403ae5c90b15efdd8585444.patch -O settings-01.patch wget https://github.com/GrapheneOS/platform_packages_apps_Settings/commit/aaba724a6858fba3754c11bfafd92b22f090c570.patch -O settings-02.patch wget https://github.com/GrapheneOS/platform_frameworks_native/commit/507304e1f59236675bfd820290b329f5f7334ec0.patch -O native-01.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/89489ff5dd9b7717f0421ca4e90bc060af1ba8b7.patch -O base-01.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/d1765c47157a99ecdc44537b5cadbb9726892967.patch -O base-02.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/cbb1a0ecd6b67735bdb735d76606bc03f6b955bf.patch -O base-03.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/4725772c0b3f0db2940e70851e145ec4ec71768b.patch -O base-04.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/19747f69235d208e3d61099c76fa47aa792fe3a7.patch -O base-05.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/e7a1aa9ed0bc69853bc83d098e15b8fa3b1881b4.patch -O base-06.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/922a7860b1baf29ff5cb53a31d01c341cd2b9ecb.patch -O base-07.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/ed183ed9122416026ed27d4877f96a545fe42316.patch -O base-08.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/c6fbe1330a77c479ea3e29b54523682d0f248420.patch -O base-09.patch wget https://github.com/GrapheneOS/platform_frameworks_base/commit/9141cac175caaf176377d088e334d0991482fd6a.patch -O base-10.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/41235bcc67a2122bc1d6a4d19e8356b3d1ada91e.patch -O av-01.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/a89f704701e6af4a4809f4bb4911af88a023226f.patch -O av-02.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/6d7cd80d77ed35efbe168f627dda021a5d8dd766.patch -O av-03.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/75fc175a08c1a8e86d4649c19fd3136121518b96.patch -O av-04.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/b023ec300f437494d6d6b23b03607e308dae43d2.patch -O av-05.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/c8117d1539078bb3339b5d5fffe063a9135c2c21.patch -O av-06.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/f06d23d824f60e98299d03f21c0715477666936d.patch -O av-07.patch wget https://github.com/GrapheneOS/platform_frameworks_av/commit/9c7408ab0710a9e36fd2a258098afde863cb6544.patch -O av-08.patch wget https://github.com/GrapheneOS/platform_packages_apps_Launcher3/commit/cfbfcefb3ce6bcd4d099cba4f45a8c6a0c02e6e6.patch -O launcher-01.patch wget https://github.com/GrapheneOS/platform_external_libxml2/commit/4a27a7f162907facfbeddf2d4ae4c6ab7c6eb15a.patch -O libxml-01.patch Signed-off-by: Tad <tad@spotco.us>
2023-10-03 14:30:46 -04:00
From 75fc175a08c1a8e86d4649c19fd3136121518b96 Mon Sep 17 00:00:00 2001
From: Ray Essick <essick@google.com>
Date: Mon, 22 Aug 2022 15:58:51 -0500
Subject: [PATCH] NdkMediaFormat_*() parameter checking
verify non-null format and name fields in the NdkMediaFormat_set/get
functions. Update unit tests to verify fixes are in place.
Bug: 243204176
Test: atest libmediandk_test
Change-Id: I551b61c96dce71310bcd1d057abad0fde021cc55
---
media/ndk/NdkMediaFormat.cpp | 97 ++++++++++++++++++++++++-
media/ndk/tests/NdkMediaFormat_test.cpp | 45 ++++++++++++
2 files changed, 141 insertions(+), 1 deletion(-)
diff --git a/media/ndk/NdkMediaFormat.cpp b/media/ndk/NdkMediaFormat.cpp
index 923453ac1b..a95e87419a 100644
--- a/media/ndk/NdkMediaFormat.cpp
+++ b/media/ndk/NdkMediaFormat.cpp
@@ -147,38 +147,80 @@ const char* AMediaFormat_toString(AMediaFormat *mData) {
EXPORT
bool AMediaFormat_getInt32(AMediaFormat* format, const char *name, int32_t *out) {
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
return format->mFormat->findInt32(name, out);
}
EXPORT
bool AMediaFormat_getInt64(AMediaFormat* format, const char *name, int64_t *out) {
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
return format->mFormat->findInt64(name, out);
}
EXPORT
bool AMediaFormat_getFloat(AMediaFormat* format, const char *name, float *out) {
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
return format->mFormat->findFloat(name, out);
}
EXPORT
bool AMediaFormat_getDouble(AMediaFormat* format, const char *name, double *out) {
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
return format->mFormat->findDouble(name, out);
}
EXPORT
bool AMediaFormat_getSize(AMediaFormat* format, const char *name, size_t *out) {
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
return format->mFormat->findSize(name, out);
}
EXPORT
bool AMediaFormat_getRect(AMediaFormat* format, const char *name,
int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) {
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
return format->mFormat->findRect(name, left, top, right, bottom);
}
EXPORT
bool AMediaFormat_getBuffer(AMediaFormat* format, const char *name, void** data, size_t *outsize) {
sp<ABuffer> buf;
+ if (format == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
if (format->mFormat->findBuffer(name, &buf)) {
*data = buf->data() + buf->offset();
*outsize = buf->size();
@@ -189,7 +231,12 @@ bool AMediaFormat_getBuffer(AMediaFormat* format, const char *name, void** data,
EXPORT
bool AMediaFormat_getString(AMediaFormat* mData, const char *name, const char **out) {
-
+ if (mData == nullptr) {
+ return false;
+ }
+ if (name == nullptr) {
+ return false;
+ }
for (size_t i = 0; i < mData->mStringCache.size(); i++) {
if (strcmp(mData->mStringCache.keyAt(i).string(), name) == 0) {
mData->mStringCache.removeItemsAt(i, 1);
@@ -212,43 +259,91 @@ bool AMediaFormat_getString(AMediaFormat* mData, const char *name, const char **
EXPORT
void AMediaFormat_setInt32(AMediaFormat* format, const char *name, int32_t value) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
format->mFormat->setInt32(name, value);
}
EXPORT
void AMediaFormat_setInt64(AMediaFormat* format, const char *name, int64_t value) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
format->mFormat->setInt64(name, value);
}
EXPORT
void AMediaFormat_setFloat(AMediaFormat* format, const char* name, float value) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
format->mFormat->setFloat(name, value);
}
EXPORT
void AMediaFormat_setDouble(AMediaFormat* format, const char* name, double value) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
format->mFormat->setDouble(name, value);
}
EXPORT
void AMediaFormat_setSize(AMediaFormat* format, const char* name, size_t value) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
format->mFormat->setSize(name, value);
}
EXPORT
void AMediaFormat_setRect(AMediaFormat* format, const char *name,
int32_t left, int32_t top, int32_t right, int32_t bottom) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
format->mFormat->setRect(name, left, top, right, bottom);
}
EXPORT
void AMediaFormat_setString(AMediaFormat* format, const char* name, const char* value) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
// AMessage::setString() makes a copy of the string
format->mFormat->setString(name, value, strlen(value));
}
EXPORT
void AMediaFormat_setBuffer(AMediaFormat* format, const char* name, const void* data, size_t size) {
+ if (format == nullptr) {
+ return;
+ }
+ if (name == nullptr) {
+ return;
+ }
// the ABuffer(void*, size_t) constructor doesn't take ownership of the data, so create
// a new buffer and copy the data into it
sp<ABuffer> buf = new ABuffer(size);
diff --git a/media/ndk/tests/NdkMediaFormat_test.cpp b/media/ndk/tests/NdkMediaFormat_test.cpp
index 668d0a4463..18690b8782 100644
--- a/media/ndk/tests/NdkMediaFormat_test.cpp
+++ b/media/ndk/tests/NdkMediaFormat_test.cpp
@@ -51,6 +51,13 @@ TEST(NdkMediaFormat_tests, test_int32) {
EXPECT_FALSE(AMediaFormat_getInt64(fmt1, "five", &i64));
EXPECT_EQ(i32, 5);
+ // verify detecting some bad parameters.
+ AMediaFormat_setInt32(nullptr, "whatever", 6);
+ AMediaFormat_setInt32(fmt1, nullptr, 6);
+
+ EXPECT_FALSE(AMediaFormat_getInt32(nullptr, "whatever", &i32));
+ EXPECT_FALSE(AMediaFormat_getInt32(fmt1, nullptr, &i32));
+
AMediaFormat_delete(fmt1);
}
@@ -67,6 +74,13 @@ TEST(NdkMediaFormat_tests, test_int64) {
EXPECT_FALSE(AMediaFormat_getInt64(fmt1, "five", &i64));
EXPECT_EQ(i64, -1);
+ // verify detecting some bad parameters.
+ AMediaFormat_setInt64(nullptr, "whatever", 6);
+ AMediaFormat_setInt64(fmt1, nullptr, 6);
+
+ EXPECT_FALSE(AMediaFormat_getInt64(nullptr, "whatever", &i64));
+ EXPECT_FALSE(AMediaFormat_getInt64(fmt1, nullptr, &i64));
+
AMediaFormat_delete(fmt1);
}
@@ -80,6 +94,13 @@ TEST(NdkMediaFormat_tests, test_size) {
EXPECT_TRUE(AMediaFormat_getSize(fmt1, "medium", &size));
EXPECT_EQ(size, 10);
+ // verify detecting some bad parameters.
+ AMediaFormat_setSize(nullptr, "whatever", 6);
+ AMediaFormat_setSize(fmt1, nullptr, 6);
+
+ EXPECT_FALSE(AMediaFormat_getSize(nullptr, "whatever", &size));
+ EXPECT_FALSE(AMediaFormat_getSize(fmt1, nullptr, &size));
+
AMediaFormat_delete(fmt1);
}
@@ -90,6 +111,14 @@ TEST(NdkMediaFormat_tests, test_float) {
AMediaFormat_setFloat(fmt1, "ship", 0.5);
EXPECT_TRUE(AMediaFormat_getFloat(fmt1, "boat", &f));
EXPECT_EQ(f, 1.5);
+
+ // verify detecting some bad parameters.
+ AMediaFormat_setFloat(nullptr, "whatever", 1.5);
+ AMediaFormat_setFloat(fmt1, nullptr, 1.5);
+
+ EXPECT_FALSE(AMediaFormat_getFloat(nullptr, "whatever", &f));
+ EXPECT_FALSE(AMediaFormat_getFloat(fmt1, nullptr, &f));
+
AMediaFormat_delete(fmt1);
}
@@ -100,6 +129,14 @@ TEST(NdkMediaFormat_tests, test_double) {
AMediaFormat_setDouble(fmt1, "dip", 0.5);
EXPECT_TRUE(AMediaFormat_getDouble(fmt1, "trouble", &d));
EXPECT_EQ(d, 100.5);
+
+ // verify detecting some bad parameters.
+ AMediaFormat_setDouble(nullptr, "whatever", 1.5);
+ AMediaFormat_setDouble(fmt1, nullptr, 1.5);
+
+ EXPECT_FALSE(AMediaFormat_getDouble(nullptr, "whatever", &d));
+ EXPECT_FALSE(AMediaFormat_getDouble(fmt1, nullptr, &d));
+
AMediaFormat_delete(fmt1);
}
@@ -111,8 +148,16 @@ TEST(NdkMediaFormat_tests, test_string) {
AMediaFormat_setString(fmt1, "stringtheory", content);
EXPECT_TRUE(AMediaFormat_getString(fmt1, "stringtheory", &out));
EXPECT_NE(out, nullptr);
+ EXPECT_NE(out, content); // should not be the original
EXPECT_EQ(strcmp(out,content), 0);
+ // verify detecting some bad parameters.
+ AMediaFormat_setString(nullptr, "whatever", content);
+ AMediaFormat_setString(fmt1, nullptr, content);
+
+ EXPECT_FALSE(AMediaFormat_getString(nullptr, "whatever", &out));
+ EXPECT_FALSE(AMediaFormat_getString(fmt1, nullptr, &out));
+
AMediaFormat_delete(fmt1);
}