Resolve build error for snprintf
[platform/core/connectivity/bluetooth-agent.git] / hf-agent / bluetooth-hf-agent.c
index 1dc8812..671432c 100644 (file)
@@ -3478,6 +3478,7 @@ static int _hf_agent_terminate_call(GDBusMethodInvocation *context)
 static int _hf_agent_dial_no(GDBusMethodInvocation *context, char *no)
 {
        int ret;
+       int prev_cmd_len = 0;
        char buf[BT_MAX_TEL_NUM_STR + 6] = {0};
 
        if (bt_hf_info.state != BT_HF_STATE_CONNECTED) {
@@ -3501,7 +3502,12 @@ static int _hf_agent_dial_no(GDBusMethodInvocation *context, char *no)
                }
 
                /* prev_cmd is meant for only meant for ATD & AT+BLDN Error handling */
-               snprintf(prev_cmd, BT_HF_CMD_BUF_SIZE, "%s", buf);
+               prev_cmd_len = snprintf(prev_cmd, BT_HF_CMD_BUF_SIZE, "%s", buf);
+
+               if (prev_cmd_len < 0) {
+                       ERR("Encoding error occured in snprintf");
+                       return BT_HF_AGENT_ERROR_INTERNAL;
+               }
 
                if (!ret)
                        return BT_HF_AGENT_ERROR_INTERNAL;