diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-01-18 15:54:12 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2019-10-06 18:56:07 +0200 |
commit | 297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42 (patch) | |
tree | 343db814deac95588517057689b985529379c365 /svl | |
parent | jsdialogs: hide one number format option initially (diff) | |
download | core-297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42.tar.gz core-297263e0cc5aa4b2b66fdc3fd17a725b9bc5fa42.zip |
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
Change-Id: I82e9b08fa099546b2d6f29c702e1440df9e6c6e0
Reviewed-on: https://gerrit.libreoffice.org/66618
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/misc/lockfilecommon.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/svl/source/misc/lockfilecommon.cxx b/svl/source/misc/lockfilecommon.cxx index f0a1db6864e0..175220a532eb 100644 --- a/svl/source/misc/lockfilecommon.cxx +++ b/svl/source/misc/lockfilecommon.cxx @@ -223,8 +223,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 ); } } |