From 446f5cacb5bbd03b89fda98b7c8ea9856b3e8167 Mon Sep 17 00:00:00 2001 From: somov Date: Wed, 31 Jan 2024 21:31:25 +0300 Subject: Fix sprintf deprecation warnings on newer macOS SDK --- util/datetime/base.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp index 9b4ec5234b7..83a17660fdf 100644 --- a/util/datetime/base.cpp +++ b/util/datetime/base.cpp @@ -258,7 +258,7 @@ void sprint_gm_date(char* buf, time_t when, long* sec) { void DateToString(char* buf, const struct tm& theTm) { Y_ENSURE(0 <= theTm.tm_year + 1900 && theTm.tm_year + 1900 <= 9999, "invalid year " + ToString(theTm.tm_year + 1900) + ", year should be in range [0, 9999]"); - sprintf(buf, "%04d%02d%02d", theTm.tm_year + 1900, theTm.tm_mon + 1, theTm.tm_mday); + snprintf(buf, DATE_BUF_LEN, "%04d%02d%02d", theTm.tm_year + 1900, theTm.tm_mon + 1, theTm.tm_mday); } void DateToString(char* buf, time_t when, long* sec) { @@ -287,7 +287,7 @@ TString DateToString(time_t when, long* sec) { TString YearToString(const struct tm& theTm) { Y_ENSURE(0 <= theTm.tm_year + 1900 && theTm.tm_year + 1900 <= 9999, "invalid year " + ToString(theTm.tm_year + 1900) + ", year should be in range [0, 9999]"); char buf[16]; - sprintf(buf, "%04d", theTm.tm_year + 1900); + snprintf(buf, 16, "%04d", theTm.tm_year + 1900); return buf; } -- cgit v1.3