Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b0cac46 authored by Myles Watson's avatar Myles Watson
Browse files

OSI: Protect cutils/properties.h from direct calls

Bug: None
Test: compile, no calls to property_get outside of libosi
      change PROPERTY_VALUE_MAX in osi/include/properties.h
      -> doesn't compile
Change-Id: I18c7b861782b1df4878da032ae3f0340dffdecab
parent bc0bbfad
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -19,11 +19,9 @@
#pragma once

#include <cstdint>
#if defined(OS_GENERIC)

#define PROPERTY_VALUE_MAX 92
#else
#include <cutils/properties.h>
#endif  // defined(OS_GENERIC)
#define BUILD_SANITY_PROPERTY_VALUE_MAX 92

// Get value associated with key |key| into |value|.
// Returns the length of the value which will never be greater than
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,14 @@

#include "osi/include/properties.h"

#if !defined(OS_GENERIC)
#undef PROPERTY_VALUE_MAX
#include <cutils/properties.h>
#if BUILD_SANITY_PROPERTY_VALUE_MAX != PROPERTY_VALUE_MAX
#error "PROPERTY_VALUE_MAX from osi/include/properties.h != the Android value"
#endif  // GENERIC_PROPERTY_VALUE_MAX != PROPERTY_VALUE_MAX
#endif  // !defined(OS_GENERIC)

int osi_property_get(const char* key, char* value, const char* default_value) {
#if defined(OS_GENERIC)
  /* For linux right now just return default value, if present */
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ cc_binary {
        "libbluetooth-binder-common",
        "libbtcore",
        "libbluetooth-types",
        "libosi",
    ],

    shared_libs: [
+1 −3
Original line number Diff line number Diff line
@@ -55,16 +55,14 @@ int main(int argc, char* argv[]) {
    return EXIT_SUCCESS;
  }

#if !defined(OS_GENERIC)
  // TODO(armansito): Remove Chromecast specific property out of here. This
  // should just be obtained from global config.
  char disable_value[PROPERTY_VALUE_MAX];
  int status = property_get(kDisableProperty, disable_value, nullptr);
  int status = osi_property_get(kDisableProperty, disable_value, nullptr);
  if (status && !strcmp(disable_value, "1")) {
    LOG(INFO) << "service disabled";
    return EXIT_SUCCESS;
  }
#endif  // !defined(OS_GENERIC)

  if (!bluetooth::Daemon::Initialize()) {
    LOG(ERROR) << "Failed to initialize Daemon";