Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
5.15.11, 6.2.6, 6.4.1, 6.5.0 FF
-
None
-
5
-
f11a9b203 (6.4), 536e17372 (dev), a50b7f500 (tqtc/lts-5.15), 4e647ab8a (tqtc/lts-6.2), b8c2a0c18 (dev), 81be57a99 (6.4), 9c63b9fda (6.5), 78db5cb64 (dev), 2a865831a (tqtc/lts-6.2), 9daf3961c (tqtc/lts-5.15), 43f6e10a7 (6.5), 115b1eab8 (dev)
-
Foundation Sprint 72
Description
The C toupper/tolower functions are locale-dependent. Given the right locale (Türkiye, e.g.):
- tolower(I) is either
- ı (LATIN SMALL LETTER DOTLESS I; if representable in current charset) or
- I (unchanged; if it isn't)
- toupper(i) is either
- İ (LATIN CAPITAL LETTER I WITH DOT ABOVE; if representable) or
- i (unchanged; if it isn't)
Both results are wrong.
Also, since toupper/tolower are UB unless the argument is 0..255 or EOF, it's UB to even feed a char! You need to cast to uchar first! So, basically all our uses of toupper/tolower are UB!
Please check your respective code bases, book patches, if any, onto this ticket, and, once merged, remove your component from the Jira field.
We have QtMiscUtils::asciiToLower() in QtCore/private/qtools_p.h. It's been backported to 5.15 We don't have asciiToUpper(). You can either port to asciiToLower() or use caseCompareAscii() (which may not be available in Qt 6.2 and 5.15), or wait for asciiToUpper() (from https://codereview.qt-project.org/c/qt/qtbase/+/449457) to make its way through the branches.
It doesn't look like we have uses in public header files. If you find one, then you need to pull the code out-of-line.
Attachments
Issue Links
- relates to
-
QTBUG-108665 Only Turkish upper i-dotted (İ) key doesn't work and triggering Home key event
- Reported
- resulted in
-
QTBUG-111262 Review <ctype.h> uses [Qt]
- Open
-
QTBUG-109556 Update moc-copy in qtscxml
- Reported
- split to
-
QTBUG-109551 Review toupper use [qtvirtualkeyboard]
- Open
-
QTCREATORBUG-28612 Review toupper/tolower uses [QtCreator]
- Closed
-
QTBUG-109520 Review toupper use [QWindowsKeyMapper]
- Closed