Commit 0e888661 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Instrument and fix calls to strncmp()

Bug: 27222508
Change-Id: I0075b4480aff52dcdc326b7bdb7154ca919ccee9
parent b1f50e1f
......@@ -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;
}
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment