From eb1d67631ed10fe220d0fc81e7a13ce646272d8b Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 16 Jan 2025 11:25:01 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=EF=BC=8C#1269=E7=82=B9?= =?utf8?q?=E5=87=BB=E5=B7=B2=E8=BF=87=E6=97=B6=E9=97=B4=E4=BD=86=E6=9C=AA?= =?utf8?q?=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=B9=E9=92=9F=EF=BC=8C=E6=89=8B?= =?utf8?q?=E8=A1=A8=E5=8D=A1=E6=AD=BB=E8=BF=87=E4=B8=80=E4=BC=9A=E6=AD=BB?= =?utf8?q?=E6=9C=BA=EF=BC=8C=E5=87=BA=E7=8E=B0=E4=BA=8C=E6=AC=A1bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/alarm/src/AlarmConfigView.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp index 33cd189f7..67b372df8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp @@ -344,6 +344,16 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep hour > 24 error!"); return; } + // 检查分钟是否在有效范围 + if (min > 59) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep min > 59 error!"); + return; + } + // 检查 week 是否在有效范围 + if (week > 127) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep week out of range!"); + return; + } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::week = %u!", week); if ((week & 0x7f) == 0x7f) { // 判断0~6位是否都为1,如若都为1,则一周7天闹钟都响应 @@ -398,9 +408,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep labelTime or labelDay error!"); return; } - showtime[12] = {0}; - sprintf(showtime, "%02d:%02d", hour, min); - // labelTime->SetTime24Hour(hour, min, 0); + memset(showtime, 0, sizeof(showtime)); + snprintf(showtime, sizeof(showtime), "%02d:%02d", hour, min);// 使用更安全的 snprintf 函数 labelTime->SetText(showtime); if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) labelDay->SetText(weekStr.c_str()); -- 2.17.1