Skip to content

Commit

Permalink
Remove usage of mFileName in ObbInfo
Browse files Browse the repository at this point in the history
This field was not being set but was used in storage_manager.cpp:89,
which constructed a String16 using the nullptr. This internally
calls strlen on the null pointer, which causes a seg fault. Since
mFileName is not being set and getFileName has no other callsites,
remove the field altogether so nobody else tries to use it and pass
in the expected value at its only callsite.

Test: Calling AStorageManager_mountObb from NDK does not result in
a crash.

Signed-off-by: Sam Gao <[email protected]>

Upstream from Meta.

Change-Id: I4374148f466dacd62c659d3c94fd309674cb2d34
  • Loading branch information
Sam Gao authored and DennySPB committed May 12, 2023
1 parent aec8b96 commit 1ceb290
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions libs/androidfw/include/androidfw/ObbFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ class ObbFile : public RefBase {
bool removeFrom(const char* filename);
bool removeFrom(int fd);

const char* getFileName() const {
return mFileName;
}

const String8 getPackageName() const {
return mPackageName;
}
Expand Down Expand Up @@ -127,8 +123,6 @@ class ObbFile : public RefBase {
/* The encryption salt. */
unsigned char mSalt[8];

const char* mFileName;

size_t mFooterStart;

bool parseObbFile(int fd);
Expand Down
2 changes: 1 addition & 1 deletion native/android/storage_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct AStorageManager : public RefBase {
return nullptr;
}

String16 fileName(obbFile->getFileName());
String16 fileName(canonicalPath);
String16 packageName(obbFile->getPackageName());
size_t length;
const unsigned char* salt = obbFile->getSalt(&length);
Expand Down

0 comments on commit 1ceb290

Please sign in to comment.