diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-07-30 08:35:27 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-08-01 08:53:59 +0000 |
| commit | a5a0c18d0abd3b567821902de499c1866615911f (patch) | |
| tree | e47af9df4d33ca3727bef0fdc8be154b89f1c4df /src/gui/doc/snippets/textdocument-end/textdocumentendsnippet.cpp | |
| parent | 4edbd011d62619540162425fefbf58fb8d82c0b0 (diff) | |
QLocale/Win: use a reasonable buffer size in qt_inIsoNametoLCID()
The old code used a blanket 64 byte buffer and strncpy()'d a locale
name into it for separator normalization ('-' → '_') followed by
lookup into windows_to_iso_list.
But the latter has space for only five character (excluding the
terminating null), so any matching string must needs be less than six
characters in size, so check and reject such inputs very early in the
function.
Then, reduce the buffer size to what windows_to_iso_list uses,
too. This means the strncpy() is guaranteed to write the terminating
null, so we can skip doing it manually, and it won't waste time
filling the remaining 58 octets of the buffer with null bytes anymore
(which it did!).
Now that both buffer sizes match, we could almost use memcmp(), but
the table isn't ready, yet, so that's left for a different patch.
Add some code comments.
Amends c17563eca879845deef542173f5fb479c9aa2d0e (though that might
have just moved existing code around; didn't check).
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I715d5435aed874ce7141ff25c2753e0886184516
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/doc/snippets/textdocument-end/textdocumentendsnippet.cpp')
0 files changed, 0 insertions, 0 deletions
