• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Revision6d7f3cd4026e7575796430add24e0b33ee3f25f9 (tree)
Time2020-04-14 23:46:52
Authorjgu21 <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

Change Summary

Incremental Difference

--- 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
@@ -537,12 +537,17 @@ com_android_internal_content_NativeLibraryHelper_findSupportedAbi_replace(
537537 Vector<ScopedUtfChars*> supportedAbis;
538538
539539 assert(apkdir_size < 256 - 15);
540- strcpy(abiFlag, apkdir.c_str());
540+ if (strlcpy(abiFlag, apkdir.c_str(), 256) != apkdir.size()) {
541+ return (jint)abiType;
542+ }
543+
541544 abiFlag[apkdir_size] = '/';
542545 abiFlag[apkdir_size + 1] = '.';
543546 for (int i = 0; i < numAbis; i++) {
544547 ScopedUtfChars* abiName = new ScopedUtfChars(env,
545548 (jstring)env->GetObjectArrayElement(javaCpuAbisToSearch, i));
549+ assert(abiName != NULL);
550+ assert(abiName->c_str() != NULL);
546551 if (strlcpy(abiFlag + apkdir_size + 2, abiName->c_str(), 256 - apkdir_size - 2)
547552 == abiName->size()) {
548553 if (access(abiFlag, F_OK) == 0) {