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

Commit 2c32372a authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Instrument and fix calls to strncmp()

Bug: 27222508
Change-Id: I0075b4480aff52dcdc326b7bdb7154ca919ccee9
parent 38f1af1f
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#define LOG_NDDEBUG 0
#define LOG_TAG "bt_btif"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -63,12 +64,6 @@
#include "btif/include/btif_debug_conn.h"
#include "btif/include/btif_media.h"

/************************************************************************************
**  Constants & Macros
************************************************************************************/

#define is_profile(profile, str) ((strlen(str) == strlen(profile)) && strncmp((const char *)profile, str, strlen(str)) == 0)

/************************************************************************************
**  Static variables
************************************************************************************/
@@ -117,6 +112,12 @@ static bool interface_ready(void) {
  return bt_hal_cbacks != NULL;
}

static bool is_profile(const char *p1, const char *p2) {
  assert(p1);
  assert(p2);
  return strlen(p1) == strlen(p2) && strncmp(p1, p2, strlen(p2)) == 0;
}

/*****************************************************************************
**
**   BLUETOOTH HAL INTERFACE FUNCTIONS
@@ -328,11 +329,11 @@ static int read_energy_info()
static void dump(int fd, const char **arguments)
{
    if (arguments != NULL && arguments[0] != NULL) {
      if (strncmp(arguments[0], "--proto-text", 11) == 0) {
      if (strncmp(arguments[0], "--proto-text", 12) == 0) {
        metrics_print(fd, true);
        return;
      }
      if (strncmp(arguments[0], "--proto-bin", 10) == 0) {
      if (strncmp(arguments[0], "--proto-bin", 11) == 0) {
        metrics_write(fd, true);
        return;
      }
+1 −0
Original line number Diff line number Diff line
@@ -559,6 +559,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_na
            if (p_srec->psm == psm                  &&
                p_srec->mx_proto_id == mx_proto_id  &&
                service_id == p_srec->service_id    &&
                p_name                              &&
                (!strncmp (p_name, (char *) p_srec->orig_service_name,
                           BTM_SEC_SERVICE_NAME_LEN) ||
                 !strncmp (p_name, (char *) p_srec->term_service_name,