Fix ASAN build error
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-utils.c
index 4df453d..9a4753f 100644 (file)
@@ -44,7 +44,7 @@ const char *bt_uuid_t2str(const uint8_t *uuid, char *buf)
        int is_bt;
 
        if (!uuid)
-               return strcpy(buf, "NULL");
+               return strncpy(buf, "NULL", strlen("NULL") + 1);
 
        is_bt = !memcmp(&uuid[4], &BT_BASE_UUID[4], HAL_UUID_LEN - 4);
 
@@ -56,9 +56,10 @@ const char *bt_uuid_t2str(const uint8_t *uuid, char *buf)
                        buf[i * 2 + shift] = '-';
                        shift++;
                }
-               sprintf(buf + i * 2 + shift, "%02x", uuid[i]);
+               snprintf(buf + i * 2 + shift, (MAX_UUID_STR_LEN -(i * 2 + shift)), "%02x", uuid[i]);
        }
 
+       ERR("uuid %s", buf);
        return buf;
 }
 
@@ -104,7 +105,7 @@ const char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf)
        const uint8_t *p;
 
        if (!bd_addr)
-               return strcpy(buf, "NULL");
+               return strncpy(buf, "NULL", strlen("NULL") + 1);
 
        p = bd_addr->address;
 
@@ -144,346 +145,345 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid)
 
 const char *_bt_hal_dump_uuid_name(int uuid_no)
 {
-    switch(uuid_no)
-    {
-        CASE_RETURN_STR(BASE)
-        CASE_RETURN_STR(SDP)
-        CASE_RETURN_STR(UDP)
-        CASE_RETURN_STR(RFCOMM)
-        CASE_RETURN_STR(TCP)
-        CASE_RETURN_STR(TCS_BIN)
-        CASE_RETURN_STR(TCS_AT)
-        CASE_RETURN_STR(ATT)
-        CASE_RETURN_STR(OBEX)
-        CASE_RETURN_STR(IP)
-        CASE_RETURN_STR(FTP)
-        CASE_RETURN_STR(HTTP)
-        CASE_RETURN_STR(WSP)
-        CASE_RETURN_STR(BNEP)
-        CASE_RETURN_STR(UPNP)
-        CASE_RETURN_STR(HIDP)
-        CASE_RETURN_STR(HardcopyControlChannel)
-        CASE_RETURN_STR(HardcopyDataChannel)
-        CASE_RETURN_STR(HardcopyNotification)
-        CASE_RETURN_STR(AVCTP)
-        CASE_RETURN_STR(AVDTP)
-        CASE_RETURN_STR(CMTP)
-        CASE_RETURN_STR(MCAPControlChannel)
-        CASE_RETURN_STR(MCAPDataChannel)
-        CASE_RETURN_STR(L2CAP)
-        CASE_RETURN_STR(ServiceDiscoveryServerServiceClassID)
-        CASE_RETURN_STR(BrowseGroupDescriptorServiceClassID)
-        CASE_RETURN_STR(SerialPort)
-        CASE_RETURN_STR(LANAccessUsingPPP)
-        CASE_RETURN_STR(DialupNetworking)
-        CASE_RETURN_STR(IrMCSync)
-        CASE_RETURN_STR(OBEXObjectPush)
-        CASE_RETURN_STR(OBEXFileTransfer)
-        CASE_RETURN_STR(IrMCSyncCommand)
-        CASE_RETURN_STR(Headset)
-        CASE_RETURN_STR(CordlessTelephony)
-        CASE_RETURN_STR(AudioSource)
-        CASE_RETURN_STR(AudioSink)
-        CASE_RETURN_STR(AV_RemoteControlTarget)
-        CASE_RETURN_STR(AdvancedAudioDistribution)
-        CASE_RETURN_STR(AV_RemoteControl)
-        CASE_RETURN_STR(AV_RemoteControlController)
-        CASE_RETURN_STR(Intercom)
-        CASE_RETURN_STR(Fax)
-        CASE_RETURN_STR(Headset_Audio_Gateway)
-        CASE_RETURN_STR(WAP)
-        CASE_RETURN_STR(WAP_CLIENT)
-        CASE_RETURN_STR(PANU)
-        CASE_RETURN_STR(NAP)
-        CASE_RETURN_STR(GN)
+       switch (uuid_no) {
+       CASE_RETURN_STR(BASE)
+       CASE_RETURN_STR(SDP)
+       CASE_RETURN_STR(UDP)
+       CASE_RETURN_STR(RFCOMM)
+       CASE_RETURN_STR(TCP)
+       CASE_RETURN_STR(TCS_BIN)
+       CASE_RETURN_STR(TCS_AT)
+       CASE_RETURN_STR(ATT)
+       CASE_RETURN_STR(OBEX)
+       CASE_RETURN_STR(IP)
+       CASE_RETURN_STR(FTP)
+       CASE_RETURN_STR(HTTP)
+       CASE_RETURN_STR(WSP)
+       CASE_RETURN_STR(BNEP)
+       CASE_RETURN_STR(UPNP)
+       CASE_RETURN_STR(HIDP)
+       CASE_RETURN_STR(HardcopyControlChannel)
+       CASE_RETURN_STR(HardcopyDataChannel)
+       CASE_RETURN_STR(HardcopyNotification)
+       CASE_RETURN_STR(AVCTP)
+       CASE_RETURN_STR(AVDTP)
+       CASE_RETURN_STR(CMTP)
+       CASE_RETURN_STR(MCAPControlChannel)
+       CASE_RETURN_STR(MCAPDataChannel)
+       CASE_RETURN_STR(L2CAP)
+       CASE_RETURN_STR(ServiceDiscoveryServerServiceClassID)
+       CASE_RETURN_STR(BrowseGroupDescriptorServiceClassID)
+       CASE_RETURN_STR(SerialPort)
+       CASE_RETURN_STR(LANAccessUsingPPP)
+       CASE_RETURN_STR(DialupNetworking)
+       CASE_RETURN_STR(IrMCSync)
+       CASE_RETURN_STR(OBEXObjectPush)
+       CASE_RETURN_STR(OBEXFileTransfer)
+       CASE_RETURN_STR(IrMCSyncCommand)
+       CASE_RETURN_STR(Headset)
+       CASE_RETURN_STR(CordlessTelephony)
+       CASE_RETURN_STR(AudioSource)
+       CASE_RETURN_STR(AudioSink)
+       CASE_RETURN_STR(AV_RemoteControlTarget)
+       CASE_RETURN_STR(AdvancedAudioDistribution)
+       CASE_RETURN_STR(AV_RemoteControl)
+       CASE_RETURN_STR(AV_RemoteControlController)
+       CASE_RETURN_STR(Intercom)
+       CASE_RETURN_STR(Fax)
+       CASE_RETURN_STR(Headset_Audio_Gateway)
+       CASE_RETURN_STR(WAP)
+       CASE_RETURN_STR(WAP_CLIENT)
+       CASE_RETURN_STR(PANU)
+       CASE_RETURN_STR(NAP)
+       CASE_RETURN_STR(GN)
        CASE_RETURN_STR(DirectPrinting)
-        CASE_RETURN_STR(ReferencePrinting)
-        CASE_RETURN_STR(Basic_Imaging_Profile)
-        CASE_RETURN_STR(ImagingResponder)
-        CASE_RETURN_STR(ImagingAutomaticArchive)
-        CASE_RETURN_STR(ImagingReferencedObjects)
-        CASE_RETURN_STR(Handsfree)
-        CASE_RETURN_STR(HandsfreeAudioGateway)
-        CASE_RETURN_STR(DirectPrintingReferenceObjectsService)
-        CASE_RETURN_STR(ReflectedUI)
-        CASE_RETURN_STR(BasicPrinting)
-        CASE_RETURN_STR(PrintingStatus)
-        CASE_RETURN_STR(HumanInterfaceDeviceService)
-        CASE_RETURN_STR(HardcopyCableReplacement)
-        CASE_RETURN_STR(HCR_Print)
-        CASE_RETURN_STR(HCR_Scan)
-        CASE_RETURN_STR(Common_ISDN_Access)
-        CASE_RETURN_STR(SIM_Access)
-        CASE_RETURN_STR(Phonebook_Access_PCE)
-        CASE_RETURN_STR(Phonebook_Access_PSE)
-        CASE_RETURN_STR(Phonebook_Access)
-        CASE_RETURN_STR(Headset_HS)
-        CASE_RETURN_STR(Message_Access_Server)
-        CASE_RETURN_STR(Message_Notification_Server)
-        CASE_RETURN_STR(Message_Access_Profile)
-        CASE_RETURN_STR(GNSS)
-        CASE_RETURN_STR(GNSS_Server)
-        CASE_RETURN_STR(ThreeD_Display)
-        CASE_RETURN_STR(ThreeD_Glasses)
-        CASE_RETURN_STR(ThreeD_Synchronization)
-        CASE_RETURN_STR(MPS_Profile)
-        CASE_RETURN_STR(MPS_SC)
-        CASE_RETURN_STR(CTN_Access_Service)
-        CASE_RETURN_STR(CTN_Notification_Service)
-        CASE_RETURN_STR(CTN_Profile)
-        CASE_RETURN_STR(PnPInformation)
-        CASE_RETURN_STR(GenericNetworking)
-        CASE_RETURN_STR(GenericFileTransfer)
-        CASE_RETURN_STR(GenericAudio)
-        CASE_RETURN_STR(GenericTelephony)
-        CASE_RETURN_STR(UPNP_Service)
-        CASE_RETURN_STR(UPNP_IP_Service)
-        CASE_RETURN_STR(ESDP_UPNP_IP_PAN)
-        CASE_RETURN_STR(ESDP_UPNP_IP_LAP)
-        CASE_RETURN_STR(ESDP_UPNP_L2CAP)
-        CASE_RETURN_STR(VideoSource)
-        CASE_RETURN_STR(VideoSink)
-        CASE_RETURN_STR(VideoDistribution)
-        CASE_RETURN_STR(HDP)
+       CASE_RETURN_STR(ReferencePrinting)
+       CASE_RETURN_STR(Basic_Imaging_Profile)
+       CASE_RETURN_STR(ImagingResponder)
+       CASE_RETURN_STR(ImagingAutomaticArchive)
+       CASE_RETURN_STR(ImagingReferencedObjects)
+       CASE_RETURN_STR(Handsfree)
+       CASE_RETURN_STR(HandsfreeAudioGateway)
+       CASE_RETURN_STR(DirectPrintingReferenceObjectsService)
+       CASE_RETURN_STR(ReflectedUI)
+       CASE_RETURN_STR(BasicPrinting)
+       CASE_RETURN_STR(PrintingStatus)
+       CASE_RETURN_STR(HumanInterfaceDeviceService)
+       CASE_RETURN_STR(HardcopyCableReplacement)
+       CASE_RETURN_STR(HCR_Print)
+       CASE_RETURN_STR(HCR_Scan)
+       CASE_RETURN_STR(Common_ISDN_Access)
+       CASE_RETURN_STR(SIM_Access)
+       CASE_RETURN_STR(Phonebook_Access_PCE)
+       CASE_RETURN_STR(Phonebook_Access_PSE)
+       CASE_RETURN_STR(Phonebook_Access)
+       CASE_RETURN_STR(Headset_HS)
+       CASE_RETURN_STR(Message_Access_Server)
+       CASE_RETURN_STR(Message_Notification_Server)
+       CASE_RETURN_STR(Message_Access_Profile)
+       CASE_RETURN_STR(GNSS)
+       CASE_RETURN_STR(GNSS_Server)
+       CASE_RETURN_STR(ThreeD_Display)
+       CASE_RETURN_STR(ThreeD_Glasses)
+       CASE_RETURN_STR(ThreeD_Synchronization)
+       CASE_RETURN_STR(MPS_Profile)
+       CASE_RETURN_STR(MPS_SC)
+       CASE_RETURN_STR(CTN_Access_Service)
+       CASE_RETURN_STR(CTN_Notification_Service)
+       CASE_RETURN_STR(CTN_Profile)
+       CASE_RETURN_STR(PnPInformation)
+       CASE_RETURN_STR(GenericNetworking)
+       CASE_RETURN_STR(GenericFileTransfer)
+       CASE_RETURN_STR(GenericAudio)
+       CASE_RETURN_STR(GenericTelephony)
+       CASE_RETURN_STR(UPNP_Service)
+       CASE_RETURN_STR(UPNP_IP_Service)
+       CASE_RETURN_STR(ESDP_UPNP_IP_PAN)
+       CASE_RETURN_STR(ESDP_UPNP_IP_LAP)
+       CASE_RETURN_STR(ESDP_UPNP_L2CAP)
+       CASE_RETURN_STR(VideoSource)
+       CASE_RETURN_STR(VideoSink)
+       CASE_RETURN_STR(VideoDistribution)
+       CASE_RETURN_STR(HDP)
        CASE_RETURN_STR(HDP_Source)
-        CASE_RETURN_STR(HDP_Sink)
-                CASE_RETURN_STR(Generic_Access)
-                CASE_RETURN_STR(Generic_Attribute)
-                CASE_RETURN_STR(Immediate_Alert)
-                CASE_RETURN_STR(Link_Loss)
-                CASE_RETURN_STR(Tx_Power)
-                CASE_RETURN_STR(Current_Time)
-                CASE_RETURN_STR(Reference_Time_Update)
-                CASE_RETURN_STR(Next_Dst_Change)
-                CASE_RETURN_STR(Glucose)
-                CASE_RETURN_STR(Health_Thermometer)
-                CASE_RETURN_STR(Device_Information)
-                CASE_RETURN_STR(Heart_Rate)
-                CASE_RETURN_STR(Phone_Alert_Status)
-                CASE_RETURN_STR(Battery_Service)
-                CASE_RETURN_STR(Blood_Pressure)
-                CASE_RETURN_STR(Alert_Notification)
-                CASE_RETURN_STR(Human_Interface_Device)
-                CASE_RETURN_STR(Scan_Parameters)
-                CASE_RETURN_STR(Running_Speed_And_Cadence)
-                CASE_RETURN_STR(Automation_IO)
-                CASE_RETURN_STR(Cycling_Speed_And_Cadence)
-                CASE_RETURN_STR(Cycling_Power)
-                CASE_RETURN_STR(Location_And_Navigation)
-                CASE_RETURN_STR(Environmental_Sensing)
-                CASE_RETURN_STR(Body_Composition)
-                CASE_RETURN_STR(User_Data)
-                CASE_RETURN_STR(Weight_Scale)
-                CASE_RETURN_STR(Bond_Management)
-                CASE_RETURN_STR(Continuous_Glucose_Monitoring)
-                CASE_RETURN_STR(Internet_Protocol_Support)
-                CASE_RETURN_STR(Indoor_Positioning)
-                CASE_RETURN_STR(Pulse_Oximeter)
-                CASE_RETURN_STR(Http_Proxy)
-                CASE_RETURN_STR(Transport_Discovery)
-                CASE_RETURN_STR(Object_Transfer)
-                CASE_RETURN_STR(Gap_Device_Name)
-                CASE_RETURN_STR(Gap_Appearance)
-                CASE_RETURN_STR(Gap_Peripheral_Privacy_Flag)
-                CASE_RETURN_STR(Gap_Reconnection_Address)
-                CASE_RETURN_STR(Gap_Peripheral_Preferred_Connection_Parameters)
-                CASE_RETURN_STR(Gatt_Service_Changed)
-                CASE_RETURN_STR(Alert_Level)
-                CASE_RETURN_STR(Tx_Power_Level)
-                CASE_RETURN_STR(Date_Time)
-                CASE_RETURN_STR(Day_Of_Week)
-                CASE_RETURN_STR(Day_Date_Time)
-               CASE_RETURN_STR(Exact_Time_256)
-                CASE_RETURN_STR(Dst_Offset)
-                CASE_RETURN_STR(Time_Zone)
-                CASE_RETURN_STR(Local_Time_Information)
-                CASE_RETURN_STR(Time_With_Dst)
-                CASE_RETURN_STR(Time_Accuracy)
-                CASE_RETURN_STR(Time_Source)
-                CASE_RETURN_STR(Reference_Time_Information)
-                CASE_RETURN_STR(Time_Update_Control_Point)
-                CASE_RETURN_STR(Time_Update_State)
-                CASE_RETURN_STR(Glucose_Measurement)
-                CASE_RETURN_STR(Battery_Level)
-                CASE_RETURN_STR(Temperature_Measurement)
-                CASE_RETURN_STR(Temperature_Type)
-                CASE_RETURN_STR(Intermediate_Temperature)
-                CASE_RETURN_STR(Measurement_Interval)
-                CASE_RETURN_STR(Boot_Keyboard_Input_Report)
-                CASE_RETURN_STR(System_Id)
-                CASE_RETURN_STR(Model_Number_String)
-                CASE_RETURN_STR(Serial_Number_String)
-                CASE_RETURN_STR(Firmware_Revision_String)
-                CASE_RETURN_STR(Hardware_Revision_String)
-                CASE_RETURN_STR(Software_Revision_String)
-                CASE_RETURN_STR(Manufacturer_Name_String)
-                CASE_RETURN_STR(Regulatory_Certification_Data_List)
-                CASE_RETURN_STR(Current_Time_Charac)
-                CASE_RETURN_STR(Magnetic_Declination)
-                CASE_RETURN_STR(Scan_Refresh)
-                CASE_RETURN_STR(Boot_Keyboard_Output_Report)
-                CASE_RETURN_STR(Boot_Mouse_Input_Report)
-                CASE_RETURN_STR(Glucose_Measurement_Context)
-                CASE_RETURN_STR(Blood_Pressure_Measurement)
-                CASE_RETURN_STR(Intermediate_Cuff_Pressure)
-                CASE_RETURN_STR(Heart_Rate_Measurement)
-                CASE_RETURN_STR(Body_Sensor_Location)
-                CASE_RETURN_STR(Heart_Rate_Control_Point)
-                CASE_RETURN_STR(Alert_Status)
-                CASE_RETURN_STR(Ringer_Control_Point)
-                CASE_RETURN_STR(Ringer_Setting)
-                CASE_RETURN_STR(Alert_Category_Id_Bit_Mask)
-                CASE_RETURN_STR(Alert_Category_Id)
-                CASE_RETURN_STR(Alert_Notification_Control_Point)
-                CASE_RETURN_STR(Unread_Alert_Status)
-                CASE_RETURN_STR(New_Alert)
-                CASE_RETURN_STR(Supported_New_Alert_Category)
-                CASE_RETURN_STR(Supported_Unread_Alert_Category)
-                CASE_RETURN_STR(Blood_Pressure_Feature)
-                CASE_RETURN_STR(Hid_Information)
-                CASE_RETURN_STR(Report_Map)
-                CASE_RETURN_STR(Hid_Control_Point)
-                CASE_RETURN_STR(Report)
-                CASE_RETURN_STR(Protocol_Mode)
-                CASE_RETURN_STR(Scan_Interval_Window)
-                CASE_RETURN_STR(Pnp_Id)
-               CASE_RETURN_STR(Glucose_Feature)
-                CASE_RETURN_STR(Record_Access_Control_Point)
-                CASE_RETURN_STR(Rsc_Measurement)
-                CASE_RETURN_STR(Rsc_Feature)
-                CASE_RETURN_STR(Sc_Control_Point)
-                CASE_RETURN_STR(Digital)
-                CASE_RETURN_STR(Analog)
-                CASE_RETURN_STR(Aggregate)
-                CASE_RETURN_STR(Csc_Measurement)
-                CASE_RETURN_STR(Csc_Feature)
-                CASE_RETURN_STR(Sensor_Location)
-                CASE_RETURN_STR(Plx_Spot_Check_Measurement)
-                CASE_RETURN_STR(Plx_Continuous_Measurement)
-                CASE_RETURN_STR(Plx_Features)
-                CASE_RETURN_STR(Cycling_Power_Measurement)
-                CASE_RETURN_STR(Cycling_Power_Vector)
-                CASE_RETURN_STR(Cycling_Power_Feature)
-                CASE_RETURN_STR(Cycling_Power_Control_Point)
-                CASE_RETURN_STR(Location_And_Speed)
-                CASE_RETURN_STR(Navigation)
-                CASE_RETURN_STR(Position_Quality)
-                CASE_RETURN_STR(Ln_Feature)
-                CASE_RETURN_STR(Ln_Control_Point)
-                CASE_RETURN_STR(Elevation)
-                CASE_RETURN_STR(Pressure)
-                CASE_RETURN_STR(Temperature)
-                CASE_RETURN_STR(Humidity)
-                CASE_RETURN_STR(True_Wind_Speed)
-                CASE_RETURN_STR(True_Wind_Direction)
-                CASE_RETURN_STR(Apparent_Wind_Speed)
-                CASE_RETURN_STR(Apparent_Wind_Direction)
-                CASE_RETURN_STR(Gust_Factor)
-                CASE_RETURN_STR(Pollen_Concentration)
-                CASE_RETURN_STR(Uv_Index)
-                CASE_RETURN_STR(Irradiance)
-                CASE_RETURN_STR(Rainfall)
-                CASE_RETURN_STR(Wind_Chill)
-                CASE_RETURN_STR(Heat_Index)
-                CASE_RETURN_STR(Dew_Point)
-                CASE_RETURN_STR(Descriptor_Value_Changed)
-                CASE_RETURN_STR(Aerobic_Threshold)
-                CASE_RETURN_STR(Age)
-                CASE_RETURN_STR(Anaerobic_Heart_Rate_Lower_Limit)
-                CASE_RETURN_STR(Anaerobic_Heart_Rate_Upper_Limit)
-                CASE_RETURN_STR(Anaerobic_Threshold)
-                CASE_RETURN_STR(Aerobic_Heart_Rate_Upper_Limit)
-                CASE_RETURN_STR(Date_Of_Birth)
-                CASE_RETURN_STR(Date_Of_Threshold_Assessment)
-                CASE_RETURN_STR(Email_Address)
-                CASE_RETURN_STR(Fat_Burn_Heart_Rate_Lower_Limit)
-                CASE_RETURN_STR(Fat_Burn_Heart_Rate_Upper_Limit)
-                CASE_RETURN_STR(First_Name)
-                CASE_RETURN_STR(Five_Zone_Heart_Rate_Limits)
-                CASE_RETURN_STR(Gender)
-                CASE_RETURN_STR(Heart_Rate_Max)
-               CASE_RETURN_STR(Height)
-                CASE_RETURN_STR(Hip_Circumference)
-                CASE_RETURN_STR(Last_Name)
-                CASE_RETURN_STR(Maximum_Recommended_Heart_Rate)
-                CASE_RETURN_STR(Resting_Heart_Rate)
-                CASE_RETURN_STR(Sport_Type_For_Aerobic_And_Anaerobic_Thresholds)
-                CASE_RETURN_STR(Three_Zone_Heart_Rate_Limits)
-                CASE_RETURN_STR(Two_Zone_Heart_Rate_Limit)
-                CASE_RETURN_STR(Vo2_Max)
-                CASE_RETURN_STR(Waist_Circumference)
-                CASE_RETURN_STR(Weight)
-                CASE_RETURN_STR(Database_Change_Increment)
-                CASE_RETURN_STR(User_Index)
-                CASE_RETURN_STR(Body_Composition_Feature)
-                CASE_RETURN_STR(Body_Composition_Measurement)
-                CASE_RETURN_STR(Weight_Measurement)
-                CASE_RETURN_STR(Weight_Scale_Feature)
-                CASE_RETURN_STR(User_Control_Point)
-                CASE_RETURN_STR(Magnetic_Flux_Density_2D)
-                CASE_RETURN_STR(Magnetic_Flux_Density_3D)
-                CASE_RETURN_STR(Language)
-                CASE_RETURN_STR(Barometric_Pressure_Trend)
-                CASE_RETURN_STR(Bond_Management_Control_Point)
-                CASE_RETURN_STR(Bond_Management_Feature)
-                CASE_RETURN_STR(Gap_Central_Address_Resolution_Support)
-                CASE_RETURN_STR(Cgm_Measurement)
-                CASE_RETURN_STR(Cgm_Feature)
-                CASE_RETURN_STR(Cgm_Status)
-                CASE_RETURN_STR(Cgm_Session_Start_Time)
-                CASE_RETURN_STR(Cgm_Session_Run_Time)
-                CASE_RETURN_STR(Cgm_Specific_Ops_Control_Point)
-                CASE_RETURN_STR(Indoor_Positioning_Configuration)
-                CASE_RETURN_STR(Latitude)
-                CASE_RETURN_STR(Longitude)
-                CASE_RETURN_STR(Local_North_Coordinate)
-                CASE_RETURN_STR(Local_East_Coordinate)
-                CASE_RETURN_STR(Floor_Number)
-                CASE_RETURN_STR(Altitude)
-                CASE_RETURN_STR(Uncertainty)
-                CASE_RETURN_STR(Location_Name)
-                CASE_RETURN_STR(Uri)
-                CASE_RETURN_STR(Http_Headers)
-                CASE_RETURN_STR(Http_Status_Code)
-                CASE_RETURN_STR(Http_Entity_Body)
-                CASE_RETURN_STR(Http_Control_Point)
-                CASE_RETURN_STR(Https_Security)
-                CASE_RETURN_STR(Tds_Control_Point)
-                CASE_RETURN_STR(Ots_Feature)
-                CASE_RETURN_STR(Object_Name)
-                CASE_RETURN_STR(Object_Type)
-                CASE_RETURN_STR(Object_Size)
-                CASE_RETURN_STR(Object_First_Created)
-                CASE_RETURN_STR(Object_Last_Modified)
-                CASE_RETURN_STR(Object_Id)
-                CASE_RETURN_STR(Object_Properties)
-                CASE_RETURN_STR(Object_Action_Control_Point)
-                CASE_RETURN_STR(Object_List_Control_Point)
-                CASE_RETURN_STR(Object_List_Filter)
-                CASE_RETURN_STR(Object_Changed)
-                CASE_RETURN_STR(Fitness_Machine_Control_Point)
-                CASE_RETURN_STR(Gatt_Characteristic_Extended_Properties)
-                CASE_RETURN_STR(Gatt_Characteristic_User_Description)
-                CASE_RETURN_STR(Gatt_Client_Characteristic_Configuration)
-                CASE_RETURN_STR(Gatt_Server_Characteristic_Configuration)
-                CASE_RETURN_STR(Gatt_Characteristic_Presentation_Format)
-                CASE_RETURN_STR(Gatt_Characteristic_Aggregate_Format)
-                CASE_RETURN_STR(Valid_Range)
-                CASE_RETURN_STR(External_Report_Reference)
-                CASE_RETURN_STR(Report_Reference)
-                CASE_RETURN_STR(Number_Of_Digitals)
-                CASE_RETURN_STR(Value_Trigger_Setting)
-                CASE_RETURN_STR(Es_Configuration)
-                CASE_RETURN_STR(Es_Measurement)
-                CASE_RETURN_STR(Es_Trigger_Setting)
-                CASE_RETURN_STR(Time_Trigger_Setting)
-                CASE_RETURN_STR(Gatt_Primary_Service_Declaration)
-                CASE_RETURN_STR(Gatt_Secondary_Service_Declaration)
-                CASE_RETURN_STR(Gatt_Include_Declaration)
-                CASE_RETURN_STR(Gatt_Characteristic_Declaration)
-        default:
-            return "--";
-    }
+       CASE_RETURN_STR(HDP_Sink)
+       CASE_RETURN_STR(Generic_Access)
+       CASE_RETURN_STR(Generic_Attribute)
+       CASE_RETURN_STR(Immediate_Alert)
+       CASE_RETURN_STR(Link_Loss)
+       CASE_RETURN_STR(Tx_Power)
+       CASE_RETURN_STR(Current_Time)
+       CASE_RETURN_STR(Reference_Time_Update)
+       CASE_RETURN_STR(Next_Dst_Change)
+       CASE_RETURN_STR(Glucose)
+       CASE_RETURN_STR(Health_Thermometer)
+       CASE_RETURN_STR(Device_Information)
+       CASE_RETURN_STR(Heart_Rate)
+       CASE_RETURN_STR(Phone_Alert_Status)
+       CASE_RETURN_STR(Battery_Service)
+       CASE_RETURN_STR(Blood_Pressure)
+       CASE_RETURN_STR(Alert_Notification)
+       CASE_RETURN_STR(Human_Interface_Device)
+       CASE_RETURN_STR(Scan_Parameters)
+       CASE_RETURN_STR(Running_Speed_And_Cadence)
+       CASE_RETURN_STR(Automation_IO)
+       CASE_RETURN_STR(Cycling_Speed_And_Cadence)
+       CASE_RETURN_STR(Cycling_Power)
+       CASE_RETURN_STR(Location_And_Navigation)
+       CASE_RETURN_STR(Environmental_Sensing)
+       CASE_RETURN_STR(Body_Composition)
+       CASE_RETURN_STR(User_Data)
+       CASE_RETURN_STR(Weight_Scale)
+       CASE_RETURN_STR(Bond_Management)
+       CASE_RETURN_STR(Continuous_Glucose_Monitoring)
+       CASE_RETURN_STR(Internet_Protocol_Support)
+       CASE_RETURN_STR(Indoor_Positioning)
+       CASE_RETURN_STR(Pulse_Oximeter)
+       CASE_RETURN_STR(Http_Proxy)
+       CASE_RETURN_STR(Transport_Discovery)
+       CASE_RETURN_STR(Object_Transfer)
+       CASE_RETURN_STR(Gap_Device_Name)
+       CASE_RETURN_STR(Gap_Appearance)
+       CASE_RETURN_STR(Gap_Peripheral_Privacy_Flag)
+       CASE_RETURN_STR(Gap_Reconnection_Address)
+       CASE_RETURN_STR(Gap_Peripheral_Preferred_Connection_Parameters)
+       CASE_RETURN_STR(Gatt_Service_Changed)
+       CASE_RETURN_STR(Alert_Level)
+       CASE_RETURN_STR(Tx_Power_Level)
+       CASE_RETURN_STR(Date_Time)
+       CASE_RETURN_STR(Day_Of_Week)
+       CASE_RETURN_STR(Day_Date_Time)
+       CASE_RETURN_STR(Exact_Time_256)
+       CASE_RETURN_STR(Dst_Offset)
+       CASE_RETURN_STR(Time_Zone)
+       CASE_RETURN_STR(Local_Time_Information)
+       CASE_RETURN_STR(Time_With_Dst)
+       CASE_RETURN_STR(Time_Accuracy)
+       CASE_RETURN_STR(Time_Source)
+       CASE_RETURN_STR(Reference_Time_Information)
+       CASE_RETURN_STR(Time_Update_Control_Point)
+       CASE_RETURN_STR(Time_Update_State)
+       CASE_RETURN_STR(Glucose_Measurement)
+       CASE_RETURN_STR(Battery_Level)
+       CASE_RETURN_STR(Temperature_Measurement)
+       CASE_RETURN_STR(Temperature_Type)
+       CASE_RETURN_STR(Intermediate_Temperature)
+       CASE_RETURN_STR(Measurement_Interval)
+       CASE_RETURN_STR(Boot_Keyboard_Input_Report)
+       CASE_RETURN_STR(System_Id)
+       CASE_RETURN_STR(Model_Number_String)
+       CASE_RETURN_STR(Serial_Number_String)
+       CASE_RETURN_STR(Firmware_Revision_String)
+       CASE_RETURN_STR(Hardware_Revision_String)
+       CASE_RETURN_STR(Software_Revision_String)
+       CASE_RETURN_STR(Manufacturer_Name_String)
+       CASE_RETURN_STR(Regulatory_Certification_Data_List)
+       CASE_RETURN_STR(Current_Time_Charac)
+       CASE_RETURN_STR(Magnetic_Declination)
+       CASE_RETURN_STR(Scan_Refresh)
+       CASE_RETURN_STR(Boot_Keyboard_Output_Report)
+       CASE_RETURN_STR(Boot_Mouse_Input_Report)
+       CASE_RETURN_STR(Glucose_Measurement_Context)
+       CASE_RETURN_STR(Blood_Pressure_Measurement)
+       CASE_RETURN_STR(Intermediate_Cuff_Pressure)
+       CASE_RETURN_STR(Heart_Rate_Measurement)
+       CASE_RETURN_STR(Body_Sensor_Location)
+       CASE_RETURN_STR(Heart_Rate_Control_Point)
+       CASE_RETURN_STR(Alert_Status)
+       CASE_RETURN_STR(Ringer_Control_Point)
+       CASE_RETURN_STR(Ringer_Setting)
+       CASE_RETURN_STR(Alert_Category_Id_Bit_Mask)
+       CASE_RETURN_STR(Alert_Category_Id)
+       CASE_RETURN_STR(Alert_Notification_Control_Point)
+       CASE_RETURN_STR(Unread_Alert_Status)
+       CASE_RETURN_STR(New_Alert)
+       CASE_RETURN_STR(Supported_New_Alert_Category)
+       CASE_RETURN_STR(Supported_Unread_Alert_Category)
+       CASE_RETURN_STR(Blood_Pressure_Feature)
+       CASE_RETURN_STR(Hid_Information)
+       CASE_RETURN_STR(Report_Map)
+       CASE_RETURN_STR(Hid_Control_Point)
+       CASE_RETURN_STR(Report)
+       CASE_RETURN_STR(Protocol_Mode)
+       CASE_RETURN_STR(Scan_Interval_Window)
+       CASE_RETURN_STR(Pnp_Id)
+       CASE_RETURN_STR(Glucose_Feature)
+       CASE_RETURN_STR(Record_Access_Control_Point)
+       CASE_RETURN_STR(Rsc_Measurement)
+       CASE_RETURN_STR(Rsc_Feature)
+       CASE_RETURN_STR(Sc_Control_Point)
+       CASE_RETURN_STR(Digital)
+       CASE_RETURN_STR(Analog)
+       CASE_RETURN_STR(Aggregate)
+       CASE_RETURN_STR(Csc_Measurement)
+       CASE_RETURN_STR(Csc_Feature)
+       CASE_RETURN_STR(Sensor_Location)
+       CASE_RETURN_STR(Plx_Spot_Check_Measurement)
+       CASE_RETURN_STR(Plx_Continuous_Measurement)
+       CASE_RETURN_STR(Plx_Features)
+       CASE_RETURN_STR(Cycling_Power_Measurement)
+       CASE_RETURN_STR(Cycling_Power_Vector)
+       CASE_RETURN_STR(Cycling_Power_Feature)
+       CASE_RETURN_STR(Cycling_Power_Control_Point)
+       CASE_RETURN_STR(Location_And_Speed)
+       CASE_RETURN_STR(Navigation)
+       CASE_RETURN_STR(Position_Quality)
+       CASE_RETURN_STR(Ln_Feature)
+       CASE_RETURN_STR(Ln_Control_Point)
+       CASE_RETURN_STR(Elevation)
+       CASE_RETURN_STR(Pressure)
+       CASE_RETURN_STR(Temperature)
+       CASE_RETURN_STR(Humidity)
+       CASE_RETURN_STR(True_Wind_Speed)
+       CASE_RETURN_STR(True_Wind_Direction)
+       CASE_RETURN_STR(Apparent_Wind_Speed)
+       CASE_RETURN_STR(Apparent_Wind_Direction)
+       CASE_RETURN_STR(Gust_Factor)
+       CASE_RETURN_STR(Pollen_Concentration)
+       CASE_RETURN_STR(Uv_Index)
+       CASE_RETURN_STR(Irradiance)
+       CASE_RETURN_STR(Rainfall)
+       CASE_RETURN_STR(Wind_Chill)
+       CASE_RETURN_STR(Heat_Index)
+       CASE_RETURN_STR(Dew_Point)
+       CASE_RETURN_STR(Descriptor_Value_Changed)
+       CASE_RETURN_STR(Aerobic_Threshold)
+       CASE_RETURN_STR(Age)
+       CASE_RETURN_STR(Anaerobic_Heart_Rate_Lower_Limit)
+       CASE_RETURN_STR(Anaerobic_Heart_Rate_Upper_Limit)
+       CASE_RETURN_STR(Anaerobic_Threshold)
+       CASE_RETURN_STR(Aerobic_Heart_Rate_Upper_Limit)
+       CASE_RETURN_STR(Date_Of_Birth)
+       CASE_RETURN_STR(Date_Of_Threshold_Assessment)
+       CASE_RETURN_STR(Email_Address)
+       CASE_RETURN_STR(Fat_Burn_Heart_Rate_Lower_Limit)
+       CASE_RETURN_STR(Fat_Burn_Heart_Rate_Upper_Limit)
+       CASE_RETURN_STR(First_Name)
+       CASE_RETURN_STR(Five_Zone_Heart_Rate_Limits)
+       CASE_RETURN_STR(Gender)
+       CASE_RETURN_STR(Heart_Rate_Max)
+       CASE_RETURN_STR(Height)
+       CASE_RETURN_STR(Hip_Circumference)
+       CASE_RETURN_STR(Last_Name)
+       CASE_RETURN_STR(Maximum_Recommended_Heart_Rate)
+       CASE_RETURN_STR(Resting_Heart_Rate)
+       CASE_RETURN_STR(Sport_Type_For_Aerobic_And_Anaerobic_Thresholds)
+       CASE_RETURN_STR(Three_Zone_Heart_Rate_Limits)
+       CASE_RETURN_STR(Two_Zone_Heart_Rate_Limit)
+       CASE_RETURN_STR(Vo2_Max)
+       CASE_RETURN_STR(Waist_Circumference)
+       CASE_RETURN_STR(Weight)
+       CASE_RETURN_STR(Database_Change_Increment)
+       CASE_RETURN_STR(User_Index)
+       CASE_RETURN_STR(Body_Composition_Feature)
+       CASE_RETURN_STR(Body_Composition_Measurement)
+       CASE_RETURN_STR(Weight_Measurement)
+       CASE_RETURN_STR(Weight_Scale_Feature)
+       CASE_RETURN_STR(User_Control_Point)
+       CASE_RETURN_STR(Magnetic_Flux_Density_2D)
+       CASE_RETURN_STR(Magnetic_Flux_Density_3D)
+       CASE_RETURN_STR(Language)
+       CASE_RETURN_STR(Barometric_Pressure_Trend)
+       CASE_RETURN_STR(Bond_Management_Control_Point)
+       CASE_RETURN_STR(Bond_Management_Feature)
+       CASE_RETURN_STR(Gap_Central_Address_Resolution_Support)
+       CASE_RETURN_STR(Cgm_Measurement)
+       CASE_RETURN_STR(Cgm_Feature)
+       CASE_RETURN_STR(Cgm_Status)
+       CASE_RETURN_STR(Cgm_Session_Start_Time)
+       CASE_RETURN_STR(Cgm_Session_Run_Time)
+       CASE_RETURN_STR(Cgm_Specific_Ops_Control_Point)
+       CASE_RETURN_STR(Indoor_Positioning_Configuration)
+       CASE_RETURN_STR(Latitude)
+       CASE_RETURN_STR(Longitude)
+       CASE_RETURN_STR(Local_North_Coordinate)
+       CASE_RETURN_STR(Local_East_Coordinate)
+       CASE_RETURN_STR(Floor_Number)
+       CASE_RETURN_STR(Altitude)
+       CASE_RETURN_STR(Uncertainty)
+       CASE_RETURN_STR(Location_Name)
+       CASE_RETURN_STR(Uri)
+       CASE_RETURN_STR(Http_Headers)
+       CASE_RETURN_STR(Http_Status_Code)
+       CASE_RETURN_STR(Http_Entity_Body)
+       CASE_RETURN_STR(Http_Control_Point)
+       CASE_RETURN_STR(Https_Security)
+       CASE_RETURN_STR(Tds_Control_Point)
+       CASE_RETURN_STR(Ots_Feature)
+       CASE_RETURN_STR(Object_Name)
+       CASE_RETURN_STR(Object_Type)
+       CASE_RETURN_STR(Object_Size)
+       CASE_RETURN_STR(Object_First_Created)
+       CASE_RETURN_STR(Object_Last_Modified)
+       CASE_RETURN_STR(Object_Id)
+       CASE_RETURN_STR(Object_Properties)
+       CASE_RETURN_STR(Object_Action_Control_Point)
+       CASE_RETURN_STR(Object_List_Control_Point)
+       CASE_RETURN_STR(Object_List_Filter)
+       CASE_RETURN_STR(Object_Changed)
+       CASE_RETURN_STR(Fitness_Machine_Control_Point)
+       CASE_RETURN_STR(Gatt_Characteristic_Extended_Properties)
+       CASE_RETURN_STR(Gatt_Characteristic_User_Description)
+       CASE_RETURN_STR(Gatt_Client_Characteristic_Configuration)
+       CASE_RETURN_STR(Gatt_Server_Characteristic_Configuration)
+       CASE_RETURN_STR(Gatt_Characteristic_Presentation_Format)
+       CASE_RETURN_STR(Gatt_Characteristic_Aggregate_Format)
+       CASE_RETURN_STR(Valid_Range)
+       CASE_RETURN_STR(External_Report_Reference)
+       CASE_RETURN_STR(Report_Reference)
+       CASE_RETURN_STR(Number_Of_Digitals)
+       CASE_RETURN_STR(Value_Trigger_Setting)
+       CASE_RETURN_STR(Es_Configuration)
+       CASE_RETURN_STR(Es_Measurement)
+       CASE_RETURN_STR(Es_Trigger_Setting)
+       CASE_RETURN_STR(Time_Trigger_Setting)
+       CASE_RETURN_STR(Gatt_Primary_Service_Declaration)
+       CASE_RETURN_STR(Gatt_Secondary_Service_Declaration)
+       CASE_RETURN_STR(Gatt_Include_Declaration)
+       CASE_RETURN_STR(Gatt_Characteristic_Declaration)
+       default:
+                       return "--";
+       }
 }
 
 const char *enum_defines(void *v, int i)
@@ -519,16 +519,16 @@ static void bonded_devices2string(char *str, void *prop, int prop_len)
        int count = prop_len / sizeof(bt_bdaddr_t);
        bt_bdaddr_t *addr = prop;
 
-       strcat(str, "{");
+       strncat(str, "{", MAX_STR_BUF_LEN - strlen(str) - 1);
 
        while (count--) {
-               strcat(str, bdaddr2str(addr));
+               strncat(str, bdaddr2str(addr), MAX_ADDR_STR_LEN);
                if (count)
-                       strcat(str, ", ");
+                       strncat(str, ", ", MAX_STR_BUF_LEN - strlen(str) - 1);
                addr++;
        }
 
-       strcat(str, "}");
+       strncat(str, "}", MAX_STR_BUF_LEN - strlen(str) - 1);
 }
 
 static void uuids2string(char *str, void *prop, int prop_len)
@@ -536,16 +536,16 @@ static void uuids2string(char *str, void *prop, int prop_len)
        int count = prop_len / sizeof(bt_uuid_t);
        bt_uuid_t *uuid = prop;
 
-       strcat(str, "{");
+       strncat(str, "{",  MAX_STR_BUF_LEN - strlen(str) - 1);
 
        while (count--) {
-               strcat(str, btuuid2str(uuid->uu));
+               strncat(str, btuuid2str(uuid->uu), MAX_UUID_STR_LEN);
                if (count)
-                       strcat(str, ", ");
+                       strncat(str, ", ",  MAX_STR_BUF_LEN - strlen(str) - 1);
                uuid++;
        }
 
-       strcat(str, "}");
+       strncat(str, "}", MAX_STR_BUF_LEN - strlen(str) - 1);
 }
 
 const char* bt_property_type_t2str(bt_property_type_t prop_type)
@@ -604,7 +604,7 @@ const char* bt_device_type_t2str(bt_device_type_t device_type)
 
 const char* bt_scan_mode_t2str(bt_scan_mode_t scan_mode)
 {
-       switch(scan_mode) {
+       switch (scan_mode) {
        case BT_SCAN_MODE_NONE:
                return "Non Scannable";
        case BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE:
@@ -617,73 +617,187 @@ const char* bt_scan_mode_t2str(bt_scan_mode_t scan_mode)
 
 }
 
-static void local_le_feat2string(char *str, const bt_local_le_features_t *f)
+static void local_le_feat2string(char *str, const bt_local_le_features_t *f, int buf_len)
 {
        uint16_t scan_num;
+       int ret;
 
-       str += sprintf(str, "{\n");
+       ret = snprintf(str, buf_len, "{\n");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       str += sprintf(str, "Privacy supported: %s,\n",
+       ret = snprintf(str, buf_len, "Privacy supported: %s,\n",
                        f->local_privacy_enabled ? "TRUE" : "FALSE");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       str += sprintf(str, "Num of advertising instances: %u,\n",
+       ret = snprintf(str, buf_len, "Num of advertising instances: %u,\n",
                        f->max_adv_instance);
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       str += sprintf(str, "PRA offloading support: %s,\n",
+       ret = snprintf(str, buf_len, "PRA offloading support: %s,\n",
                        f->rpa_offload_supported ? "TRUE" : "FALSE");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       str += sprintf(str, "Num of offloaded IRKs: %u,\n",
+       ret = snprintf(str, buf_len, "Num of offloaded IRKs: %u,\n",
                        f->max_irk_list_size);
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       str += sprintf(str, "Num of offloaded scan filters: %u,\n",
+       ret = snprintf(str, buf_len, "Num of offloaded scan filters: %u,\n",
                        f->max_adv_filter_supported);
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       scan_num = (f->scan_result_storage_size_hibyte << 8) +
-               f->scan_result_storage_size_lobyte;
+       scan_num = f->scan_result_storage_size;
 
-       str += sprintf(str, "Num of offloaded scan results: %u,\n", scan_num);
+       ret = snprintf(str, buf_len, "Num of offloaded scan results: %u,\n", scan_num);
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       str += sprintf(str, "Activity & energy report support: %s\n",
+       ret = snprintf(str, buf_len, "Activity & energy report support: %s\n",
                        f->activity_energy_info_supported ? "TRUE" : "FALSE");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
+
+       ret = snprintf(str, buf_len, "LE 2M PHY Support: %s\n",
+                       f->le_2m_phy_supported ? "TRUE" : "FALSE");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
+
+       ret = snprintf(str, buf_len, "LE CODED PHY Support: %s\n",
+                       f->le_coded_phy_supported ? "TRUE" : "FALSE");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
+       str += ret;
+       buf_len -= ret;
 
-       sprintf(str, "}");
+       ret = snprintf(str, buf_len, "}");
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               return;
+       }
 }
 
 const char *btproperty2str(const bt_property_t *property)
 {
        bt_service_record_t *rec;
-       static char buf[4096];
+       static char buf[MAX_STR_BUF_LEN];
+       int buf_len = MAX_STR_BUF_LEN;
+       int ret;
        char *p;
 
-       p = buf + sprintf(buf, "type=%s len=%d val=",
+       memset(buf, 0x00, MAX_STR_BUF_LEN);
+       ret = snprintf(buf, buf_len, "type=%s len=%d val=",
                        bt_property_type_t2str(property->type),
                        property->len);
+       if (0 > ret) {
+               ERR("snprintf failed with %d", ret);
+               goto failed;
+       }
+       p = buf + ret;
+       buf_len -= ret;
 
        switch (property->type) {
        case BT_PROPERTY_BDNAME:
        case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
-               snprintf(p, property->len + 1, "%s",
+               ret = snprintf(p, buf_len, "%s",
                                ((bt_bdname_t *) property->val)->name);
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_BDADDR:
-               sprintf(p, "%s", bdaddr2str((bt_bdaddr_t *) property->val));
+               ret = snprintf(p, buf_len, "%s", bdaddr2str((bt_bdaddr_t *) property->val));
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_CLASS_OF_DEVICE:
-               sprintf(p, "%06x", *((unsigned int *) property->val));
+               ret = snprintf(p, buf_len, "%06x", *((unsigned int *) property->val));
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_TYPE_OF_DEVICE:
-               sprintf(p, "%s", bt_device_type_t2str(
+               ret = snprintf(p, buf_len, "%s", bt_device_type_t2str(
                                        *((bt_device_type_t *) property->val)));
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_REMOTE_RSSI:
-               sprintf(p, "%d", *((char *) property->val));
+               ret = snprintf(p, buf_len, "%d", *((char *) property->val));
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
-               sprintf(p, "%d", *((unsigned int *) property->val));
+               ret = snprintf(p, buf_len, "%d", *((unsigned int *) property->val));
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_ADAPTER_SCAN_MODE:
-               sprintf(p, "%s",
+               ret = snprintf(p, buf_len, "%s",
                                bt_scan_mode_t2str(*((bt_scan_mode_t *) property->val)));
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
                bonded_devices2string(p, property->val, property->len);
@@ -693,19 +807,30 @@ const char *btproperty2str(const bt_property_t *property)
                break;
        case BT_PROPERTY_SERVICE_RECORD:
                rec = property->val;
-               sprintf(p, "{%s, %d, %s}", btuuid2str(rec->uuid.uu),
+               ret = snprintf(p, buf_len, "{%s, %d, %s}", btuuid2str(rec->uuid.uu),
                                rec->channel, rec->name);
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        case BT_PROPERTY_LOCAL_LE_FEATURES:
-               local_le_feat2string(p, property->val);
+               local_le_feat2string(p, property->val, buf_len);
                break;
        case BT_PROPERTY_REMOTE_VERSION_INFO:
        case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
        default:
-               sprintf(p, "%p", property->val);
+               ret = snprintf(p, buf_len, "%p", property->val);
+               if (0 > ret) {
+                       ERR("snprintf failed with %d", ret);
+                       goto failed;
+               }
+               buf_len -= ret;
                break;
        }
 
+failed:
        return buf;
 }
 
@@ -713,8 +838,6 @@ bt_service_id_t _bt_convert_uuid_string_to_service_id(const char *uuid)
 {
        bt_service_id_t service_id = BT_RES_SERVICE_ID;
 
-       DBG("+");
-
        if (!strcasecmp(uuid, BT_HAL_HFP_AUDIO_GATEWAY_UUID))
                service_id = BT_HFP_SERVICE_ID;
        else if (!strcasecmp(uuid, BT_HAL_HSP_AUDIO_GATEWAY_UUID))
@@ -763,7 +886,6 @@ bt_service_id_t _bt_convert_uuid_string_to_service_id(const char *uuid)
                ERR("Unknwon Service uuid, return BT_RES_SERVICE_ID");
 
        DBG("service_id = [%d]", service_id);
-       DBG("-");
        return service_id;
 }
 
@@ -823,7 +945,7 @@ char *_bt_convert_service_id_to_uuid_string(bt_service_id_t service_id)
                return g_strdup(BT_HAL_IOTIVITY_UUID);
 #endif
        default:
-               ERR("Unknwon Service id: %d, return NULL");
+               ERR("Unknwon Service id: %d, return NULL", service_id);
        }
 
        DBG("-");