diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-01-18 15:54:12 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-01-21 09:37:44 +0100 |
commit | 113536e974d7ebbbc484b0ef40406f9b4d14e511 (patch) | |
tree | d43dc6f98ec4fb2fb87df156260710d6fb0f8479 /svl | |
parent | 5e1e912010f35ee9ba5f387bdee82363d32a8105 (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
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 88850e7687f9..483b52982de5 100644 --- a/svl/source/misc/lockfilecommon.cxx +++ b/svl/source/misc/lockfilecommon.cxx @@ -200,8 +200,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 ); } } |