https://bugs.documentfoundation.org/show_bug.cgi?id=166195

Buovjaga <ilmari.lauhakan...@libreoffice.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ilmari.lauhakangas@libreoff
                   |                            |ice.org

--- Comment #5 from Buovjaga <ilmari.lauhakan...@libreoffice.org> ---
(In reply to gplhust955 from comment #0)
> The following patch implements the proposed solution. It has been tested
> locally and resolves the described inconsistent behavior.
> 
> diff --git a/svl/source/numbers/zforfind.cxx
> b/svl/source/numbers/zforfind.cxx
> index 2b91fa662..648c1007f 100644
> --- a/svl/source/numbers/zforfind.cxx
> +++ b/svl/source/numbers/zforfind.cxx
> @@ -1111,7 +1111,11 @@ sal_uInt16 ImpSvNumberInputScan::ImplGetYear(
> sal_uInt16 nIndex )
>      // leading zero as convention.
>      if (nLen <= 6)
>      {
> -        nYear = static_cast<sal_uInt16>(sStrArray[nNums[nIndex]].toInt32());
> +        sal_Int32 temp = sStrArray[nNums[nIndex]].toInt32();
> +        // safely convert int32 to uint16 by capping values at 65535
> +        // downstream code will cast uint16 to int16(where values >32767
> become negative and are considerd invalid for year)
> +        nYear = temp < 65536 ? temp : 65535;
> +
>          // A year in another, not Gregorian CE era is never expanded.
>          // A year < 100 entered with at least 3 digits with leading 0 is
> taken
>          // as is without expansion.
> 
> 
> I have implemented and tested this fix. However, I am currently unfamiliar
> with the process for contributing code changes to the Calc/LibreOffice
> project. Guidance on submitting this patch would be appreciated.

Create a Gerrit account and set up the SSH connection:
https://wiki.documentfoundation.org/Development/gerrit

Submit the patch:
https://wiki.documentfoundation.org/Development/gerrit/SubmitPatch

Send a license statement to the mailing list:
https://wiki.documentfoundation.org/Development/GetInvolved#License_statement

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to