commit | d52ac3c0e23380c77e4e0598bb352f1d7beb8435 | [log] [tgz] |
---|---|---|
author | Aishwarya Mallampati <amallampati@google.com> | Wed May 10 21:54:43 2023 +0000 |
committer | android-t1 <android-t1@t2mobile.com> | Wed Aug 02 17:45:09 2023 +0800 |
tree | a1022f906286262fbd8242b8a993c09f50a54322 | |
parent | 6f4fc51bbe1006e5def1bc58576cc04bac95898d [diff] |
Update file permissions using canonical path Bug: 264880895 Bug: 264880689 Test: atest android.telephonyprovider.cts.MmsPartTest atest CtsTelephonyTestCases Sanity check - sending and receiving sms and mms manually (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6743638a096c32627f398efd2ea78f08b8a2db8c) Merged-In: I8dd888ea31ec07c9f0de38eb8e8170d3ed255686 Change-Id: I8dd888ea31ec07c9f0de38eb8e8170d3ed255686
diff --git a/src/com/android/providers/telephony/MmsProvider.java b/src/com/android/providers/telephony/MmsProvider.java index b1462ae..cda84fd 100644 --- a/src/com/android/providers/telephony/MmsProvider.java +++ b/src/com/android/providers/telephony/MmsProvider.java
@@ -1051,15 +1051,16 @@ uri.getPathSegments().get(1); try { + File canonicalFile = new File(path).getCanonicalFile(); String partsDirPath = getContext().getDir(PARTS_DIR_NAME, 0).getCanonicalPath(); - if (!new File(path).getCanonicalPath().startsWith(partsDirPath)) { + if (!canonicalFile.getPath().startsWith(partsDirPath + '/')) { EventLog.writeEvent(0x534e4554, "240685104", Binder.getCallingUid(), (TAG + " update: path " + path + " does not start with " + partsDirPath)); return 0; } // Reset the file permission back to read for everyone but me. - Os.chmod(path, 0644); + Os.chmod(canonicalFile.getPath(), 0644); if (LOCAL_LOGV) { Log.d(TAG, "MmsProvider.update chmod is successful for path: " + path); }