/** * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #define MAX_PATH_LENGTH 1035 int main() { FILE *fp; char path[MAX_PATH_LENGTH]; void *libHandle; static int (*real_FDK_getBitCnt)(HANDLE_FDK_BITBUF) = NULL; fp = popen("find / -name libbluetooth.so 2>/dev/null ", "r"); if (fp == NULL) { return EXIT_SUCCESS; } while (fgets(path, sizeof(path) - 1, fp) != NULL) { path[strlen(path) - 1] = '\0'; /* remove \n */ libHandle = dlopen(path, RTLD_LAZY); if (libHandle) { real_FDK_getBitCnt = (int (*)( HANDLE_FDK_BITBUF))dlsym(libHandle, "FDK_getBitCnt"); dlclose(libHandle); if (real_FDK_getBitCnt) { pclose(fp); /* The symbol of function is present, it means there is no fix patch */ return EXIT_VULNERABLE; } } } pclose(fp); return EXIT_SUCCESS; }