From: Myungki Lee Date: Wed, 19 Jul 2017 09:26:30 +0000 (+0900) Subject: Fix incorrect use of strncat X-Git-Tag: submit/tizen/20170725.032000~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5aadeadeb74da91830eb4948f5ff82536c9315b4;p=platform%2Fcore%2Fapi%2Fnotification.git Fix incorrect use of strncat Change-Id: I5b31f2215f161d45f37ba12dbcbf14ceb6fc9f13 Signed-off-by: Myungki Lee --- diff --git a/src/notification.c b/src/notification.c index 9ed7016e..b9c8f859 100755 --- a/src/notification.c +++ b/src/notification.c @@ -555,11 +555,20 @@ EXPORT_API int notification_get_text(notification_h noti, for (temp_str = (char *)get_str; *temp_str != '\0'; temp_str++) { if (*temp_str != '%') { - strncat(result_str, temp_str, 1); + if (NOTI_TEXT_RESULT_LEN - 1 > strlen(result_str)) { + strncat(result_str, temp_str, 1); + } else { + NOTIFICATION_WARN("The buffer is full"); + break; + } } else { if (*(temp_str + 1) == '%') { - strncat(result_str, temp_str, - 1); + if (NOTI_TEXT_RESULT_LEN - 1 > strlen(result_str)) { + strncat(result_str, temp_str, 1); + } else { + NOTIFICATION_WARN("The buffer is full"); + break; + } } else if (*(temp_str + 1) == 'd') { /* Get var Type */ ret_variable_int = 0; @@ -740,10 +749,20 @@ EXPORT_API int notification_get_text(notification_h noti, temp_str += 3; } else { - strncat(result_str, temp_str, 1); + if (NOTI_TEXT_RESULT_LEN - 1 > strlen(result_str)) { + strncat(result_str, temp_str, 1); + } else { + NOTIFICATION_WARN("The buffer is full"); + break; + } } } else { - strncat(result_str, temp_str, 1); + if (NOTI_TEXT_RESULT_LEN - 1 > strlen(result_str)) { + strncat(result_str, temp_str, 1); + } else { + NOTIFICATION_WARN("The buffer is full"); + break; + } } } }