Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-base: Commit

frameworks/base


Commit MetaInfo

Revisiónaf3f368f57538a3e39d62bbcbd91269d7f8c2040 (tree)
Tiempo2019-09-20 15:24:11
Autorjgu21 <jinghui.gu@inte...>
CommiterChih-Wei Huang

Log Message

Fix KW issues on PRC compatibility

Fix KW issues on PRC compatibility,introduced by below commit.
https://android.intel.com/#/c/484542/

Change-Id: Ib10899655dd2a18569387dbafbe33856acf5df59
Tracked-On: https://jira01.devtools.intel.com/browse/OAM-26904
Signed-off-by: jgu21 <jinghui.gu@intel.com>
Reviewed-on: https://android.intel.com:443/487804

Cambiar Resumen

Diferencia

--- a/core/jni/abipicker/ABIPicker.cpp
+++ b/core/jni/abipicker/ABIPicker.cpp
@@ -44,12 +44,15 @@ static const char* iaRelated[] = {"intel", "intl", "atom", "x86", "x64"};
4444
4545 //////////////////////////////////////////////////////////////////////
4646 void getConfig(const char* cfgFile , Vector<char*>& cfgVec) {
47- FILE* fp = fopen(cfgFile, "r");
48- assert(fp != NULL);
4947 int read = -1;
5048 char *line = NULL;
5149 size_t len = 0;
5250
51+ FILE* fp = fopen(cfgFile, "r");
52+ if (fp == NULL) {
53+ return;
54+ }
55+
5356 while ((read = getline(&line, &len, fp)) != -1) {
5457 int i = 0 , j = 0;
5558 char *cfgline = (char*)malloc(len);
@@ -262,10 +265,10 @@ bool ABIPicker::compare(char* armRef, char* iaRef,
262265
263266 Vector<char*>* iaRefList = getLibList(iaRef);
264267 Vector<char*>* armRefList = getLibList(armRef);
268+ if (iaRefList == NULL || armRefList == NULL) {
269+ break;
270+ }
265271
266- // if contains the key words in iaRelated, just return true
267- assert(iaRefList != NULL);
268- assert(armRefList != NULL);
269272 if (isReliableLib(*iaRefList)) {
270273 *result = iaRef;
271274 break;
@@ -341,27 +344,29 @@ bool ABIPicker::compareLibList(Vector<char*>& iaRefList,
341344 // till the end, and the last result is equal
342345 if (itArm == armRefList.end() && isEqual){
343346 return true;
344- } else {
345- return false;
346347 }
348+
349+ return false;
347350 }
348351
349352 bool ABIPicker::compare3rdPartyLibList(
350353 char* iaRef, char* armRef,
351354 size_t* iaIsvLibCount, size_t* armIsvLibCount) {
355+ bool result = true;
356+
352357 Vector<char*>* iaRefList = getLibList(iaRef);
353358 Vector<char*>* armRefList = getLibList(armRef);
354- assert(iaRefList != NULL);
355- assert(armRefList != NULL);
356-
357- Vector<char*>* armRef3rdPartyLibList = new Vector<char*>();
358- Vector<char*>::iterator itArm = armRefList->begin();
359+ if (iaRefList == NULL || armRefList == NULL) {
360+ return result;
361+ }
359362
360- // Load thirdPartyso
361363 if (!thirdload) {
362364 getConfig(THIRDPARTY, thirdPartySO);
363365 thirdload = true;
364366 }
367+
368+ Vector<char*>* armRef3rdPartyLibList = new Vector<char*>();
369+ Vector<char*>::iterator itArm = armRefList->begin();
365370 while (itArm != armRefList->end()) {
366371 char* armLibName = *itArm;
367372 if (isInThirdPartySOList(armLibName)) {
@@ -385,11 +390,10 @@ bool ABIPicker::compare3rdPartyLibList(
385390
386391 itIa++;
387392 }
388- bool result = compareLibList(*iaRef3rdPartyLibList, *armRef3rdPartyLibList);
393+ result = compareLibList(*iaRef3rdPartyLibList, *armRef3rdPartyLibList);
389394
390- //release the memory
391- free(armRef3rdPartyLibList);
392- free(iaRef3rdPartyLibList);
395+ delete armRef3rdPartyLibList;
396+ delete iaRef3rdPartyLibList;
393397 return result;
394398 }
395399
@@ -472,11 +476,9 @@ bool ABIPicker::foundMixedELF(const char* abiName) {
472476 //////////////////////////////////////////////////////////////////////
473477 ABIPicker::ABIPicker(const char* pkgName, Vector<ScopedUtfChars*> abiList) {
474478 mLibList = new Vector<struct libInfo*>();
475- mpkgName = (char*)malloc(strlen(pkgName)+1);
479+ mpkgName = strdup(pkgName);
476480 if (!mpkgName) {
477481 P_LOG("ABIPicker Construct Allocated space fails");
478- } else {
479- snprintf(mpkgName, strlen(pkgName)+1, "%s", pkgName);
480482 }
481483 Vector<ScopedUtfChars*>::iterator it = abiList.begin();
482484 while (it != abiList.end()) {
--- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
+++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
@@ -539,12 +539,17 @@ com_android_internal_content_NativeLibraryHelper_findSupportedAbi_replace(
539539 Vector<ScopedUtfChars*> supportedAbis;
540540
541541 assert(apkdir_size < 256 - 15);
542- strcpy(abiFlag, apkdir.c_str());
542+ if (strlcpy(abiFlag, apkdir.c_str(), 256) != apkdir.size()) {
543+ return (jint)abiType;
544+ }
545+
543546 abiFlag[apkdir_size] = '/';
544547 abiFlag[apkdir_size + 1] = '.';
545548 for (int i = 0; i < numAbis; i++) {
546549 ScopedUtfChars* abiName = new ScopedUtfChars(env,
547550 (jstring)env->GetObjectArrayElement(javaCpuAbisToSearch, i));
551+ assert(abiName != NULL);
552+ assert(abiName->c_str() != NULL);
548553 if (strlcpy(abiFlag + apkdir_size + 2, abiName->c_str(), 256 - apkdir_size - 2)
549554 == abiName->size()) {
550555 if (access(abiFlag, F_OK) == 0) {
Show on old repository browser