summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-18 15:54:12 +0100
committerAron Budea <aron.budea@collabora.com>2019-02-06 02:42:19 +0100
commit2c652561e7637d662f94157259fddcd666984751 (patch)
tree22c556b5c6f072a5059ac43a9bdd585f43eb5945 /svl
parentf98689833179403ac5ed3db8e1ce1db1a64fbe7e (diff)
Avoid -Werror=format-{overflow,truncation}=
...as emitted by at least GCC 8.2 with --enable-optimized, by making the buffers large enough for the (hypothetical) largest values of the various date/time components Reviewed-on: https://gerrit.libreoffice.org/66618 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> (cherry picked from commit 113536e974d7ebbbc484b0ef40406f9b4d14e511) Change-Id: I82e9b08fa099546b2d6f29c702e1440df9e6c6e0
Diffstat (limited to 'svl')
-rw-r--r--svl/source/misc/lockfilecommon.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/svl/source/misc/lockfilecommon.cxx b/svl/source/misc/lockfilecommon.cxx
index 6768b7b07f87..eb5754eb0476 100644
--- a/svl/source/misc/lockfilecommon.cxx
+++ b/svl/source/misc/lockfilecommon.cxx
@@ -202,8 +202,9 @@ OUString LockFileCommon::GetCurrentLocalTime()
oslDateTime aDateTime;
if ( osl_getDateTimeFromTimeValue( &aLocTime, &aDateTime ) )
{
- char pDateTime[20];
- sprintf( pDateTime, "%02d.%02d.%4d %02d:%02d", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes );
+ char pDateTime[sizeof("65535.65535.-32768 65535:65535")];
+ // reserve enough space for hypothetical max length
+ sprintf( pDateTime, "%02" SAL_PRIuUINT32 ".%02" SAL_PRIuUINT32 ".%4" SAL_PRIdINT32 " %02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32, sal_uInt32(aDateTime.Day), sal_uInt32(aDateTime.Month), sal_Int32(aDateTime.Year), sal_uInt32(aDateTime.Hours), sal_uInt32(aDateTime.Minutes) );
aTime = OUString::createFromAscii( pDateTime );
}
}