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

Commit b18b8fd7 authored by George Burgess IV's avatar George Burgess IV
Browse files

bt: don't return the address of a stack-allocated string

`char foo[] = "bar";` makes a stack-resident `char[4]`. The standard
ways of getting a not-stack-allocated string are:
- `const char *foo = "bar"` (`foo` will point to a `char[4]` in rodata.
  casting away the const here leads to badness if the string is
  modified.)
- `static char foo[] = "bar"` (`foo` will point to a `char[4]` in a
  writeable section of memory that lives for the life of the program.)

Since we return a non-const `char *` here, and since this method is a
stub, the latter seems more appropriate.

Bug: 162984360
Tag: #security
Test: TreeHugger
Change-Id: I51bd4a2d8e2e3826809a1bdc9743d2d1cb62870f
parent 3c19d92f
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1277,9 +1277,8 @@ void bluetooth::shim::BTM_SecClearSecurityFlags(const RawAddress& bd_addr) {
}

char* bluetooth::shim::BTM_SecReadDevName(const RawAddress& address) {
  char name[] = "TODO: See if this is needed";
  char* n = name;
  return n;
  static char name[] = "TODO: See if this is needed";
  return name;
}

bool bluetooth::shim::BTM_SecAddRmtNameNotifyCallback(