Resolve build error for snprintf 48/221048/2
authorhimanshu <h.himanshu@samsung.com>
Thu, 26 Dec 2019 13:45:17 +0000 (19:15 +0530)
committerhimanshu <h.himanshu@samsung.com>
Fri, 27 Dec 2019 09:53:38 +0000 (15:23 +0530)
Change-Id: Ib2a7eb9d7fb28e448b33766d8b040949e4c2533e
Signed-off-by: himanshu <h.himanshu@samsung.com>
hf-agent/bluetooth-hf-agent.c
map-agent/bluetooth_map_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;
index a8a2311..65fadc7 100644 (file)
@@ -582,6 +582,7 @@ void _get_msg_timestamp(time_t *ltime, char *timestamp)
        FN_START;
        struct tm local_time;
        int year;
+       int buf_len = 0;
        int month;
 
        if (!localtime_r(ltime, &local_time))
@@ -589,9 +590,12 @@ void _get_msg_timestamp(time_t *ltime, char *timestamp)
 
        year = local_time.tm_year + 1900; /* years since 1900 */
        month = local_time.tm_mon + 1; /* months since January */
-       snprintf(timestamp, 16, "%04d%02d%02dT%02d%02d%02d", year, month,
-                                       local_time.tm_mday, local_time.tm_hour,
-                                       local_time.tm_min, local_time.tm_sec);
+       buf_len = snprintf(timestamp, 16, "%04hu%02hu%02huT%02hu%02hu%02hu",(unsigned short int)year, (unsigned short int)month,
+                                       (unsigned short int)local_time.tm_mday, (unsigned short int)local_time.tm_hour,
+                                       (unsigned short int)local_time.tm_min, (unsigned short int)local_time.tm_sec);
+
+       if (buf_len < 0)
+               ERR("Encoding error occured in snprintf");
 
        FN_END;
 }