summaryrefslogtreecommitdiffstats
path: root/src/corelib
Commit message (Collapse)AuthorAgeFilesLines
* QStandardPaths/Unix: improve the XDG_RUNTIME_DIR creation/detectionThiago Macieira2020-12-071-42/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, use QT_MKDIR instead of QFileSystemEngine::createDirectory(), as the latter can't create a directory with the right permissions. That would allow an attacker to briefly obtain access to the runtime dir between the mkdir() and chmod() system calls. Second, make sure that if the target already exists that it is a directory and not a symlink (even to a directory). If it is a symlink that belongs to another user, it can be changed to point to another place, which we won't like. And as a bonus, we're printing more information to the user in case something went wrong. Sample outputs: QStandardPaths: runtime directory '/root' is not owned by UID 1000, but a directory permissions 0700 owned by UID 0 GID 0 QStandardPaths: runtime directory '/dev/null' is not a directory, but a character device, socket or FIFO permissions 0666 owned by UID 0 GID 0 QStandardPaths: runtime directory '/etc/passwd' is not a directory, but a regular file permissions 0644 owned by UID 0 GID 0 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-tjmaciei' QStandardPaths: runtime directory '/tmp/runtime-tjmaciei' is not a directory, but a symbolic link to a directory permissions 0755 owned by UID 1000 GID 100 Change-Id: Iea47e0f8fc8b40378df7fffd16248b663794c613 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit ad5a65b6a2bfca1658634e380559d14ea1e904a4 plus a lot of others) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: Kill calls to deprecated func in API 29Piotr Mikolajczyk2020-12-071-56/+8
| | | | | | | | | | | | | | | | | Since API 29 functions: - getExternalStoragePublicDirectory - getExternalStorageDirectory are deprecated and no longer return directly accessible path. This patch replaces calls to those with suggested call to Context.getExternalFilesDir(String) Task-number: QTBUG-87803 Change-Id: I36bc5d5b72a80017996445af0d577aacf5e112d3 Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit e1440dd7bc1a5da9a536f88b9733d04ec8fa6e61) Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Containers: call constructors even for primitive typesGiuseppe D'Angelo2020-12-013-25/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Trivial types are automatically classified as Q_PRIMITIVE_TYPE, but it doesn't mean that they can be initialized with memset(0) (notably, pointers to data members on Itanium ABIs are initialized with -1, not 0). Drop that kind of optimization, and always value-initialize objects in containers. Fix the documentation to match as well. This is a rework of f6f68409a40beaa5f034c411dd7e296c7828d8fd and 82b13880b994ff9b87710e0729e32035ab3b63a4 in Qt 6. [ChangeLog][QtCore][QTypeInfo] The semantics of Q_PRIMITIVE_TYPE have been slightly changed. Qt now value-initializes types marked as primitive (which, by default, include trivial types) instead of simply using memset(0), which is wrong in some corner cases. Change-Id: Ib61396be883424e2f03a9f3bbce1eaddce6aa731 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 76671a57b5418ec98fe2c94a963728ac3306dc82) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QRectF/QPointF/QSizeF: document that operator== and != are fuzzyGiuseppe D'Angelo2020-11-183-8/+37
| | | | | | | | | | | This has been the case for a _very_ long time, and I can't believe this hasn't been documented anywhere. Change-Id: Ib157edf14e87a6f546c155496f70a760ab218cca Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit cca62a7360a117880eea5821fd7403d68a1431c8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMutex: order reads from QMutexPrivate::waiters and QBasicMutex::d_ptr in ↵Alexander Kartashov2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QBasicMutex::lockInternal() Threads that unlock and lock a mutex at the same time perform the following operations: Thread 1 Thread 2 -------- -------- QBasicMutex::lockInternal() QBasicMutex::unlockInternal() d_ptr.testAndSetOrdered(..., d) d = d_ptr.loadAcquire() d->waiters.loadRelaxed(); (1) d->waiters.fetchAndAddRelease() (2) d_ptr.testAndSetRelease(d, 0) (3) d->derefWaiters() (4) d->waiters.testAndSetRelaxed(...) (5) if (d != d_ptr.loadAcquire()) (6) d->wait() The operation (1) isn't serialized with the operation (6) so its memory effect may be observed before the effect of the operation (1). However, if memory effects are observed in the following order: (6) -> (1) -> (2) -> (3) -> (4) -> (5) then Thread 1 doesn't notice that Thread 2 updates d_ptr and goes to sleep with d pointing to a stale object, this object isn't reachable since d_ptr is zeroed so Thread 1 cannot be woken up. The patch adds the "acquire" barrier into the operation (1) so that it cannot be reordered with the operation (6). Fixes: QTBUG-88247 Change-Id: I1d0c405c0bf5080ec1815d351b9b4b75efeab21a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d08e3b6de16118becaada17a58aed4042f400a5a)
* Q_PRIMITIVE_TYPE: improve the documentationGiuseppe D'Angelo2020-11-101-2/+3
| | | | | | | | | | | | | | A key piece of information missing from Q_PRIMITIVE_TYPE documentation is that for them value initialization must equal memset()ting with zeroes. A type like QPoint is primitive because `QPoint p;` is initialized to (0, 0), but a type like QSize is movable (and NOT primitive) because `QSize s;` is actually initialized to (-1, -1). Amend the docs. Change-Id: I121684810da46be5d0579c7d3de945149390a32a Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit b8b75cdcfa71189c7726607be7b66d0ddeaae372) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Revert changes in strto(u)ll.c to avoid integer overflowsRobert Loehning2020-11-051-0/+4
| | | | | | | | Found in oss-fuzz issue 26045. Change-Id: Id9eac1b4f67ad9bbe2d92dd69cd03338a6ced74e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 2096400d6e8249e49df049f9600073fb2219c97a)
* Fix locale look-up when language is unspecifiedEdward Welbourne2020-10-281-5/+15
| | | | | | | | | | | | Looking up a locale with unspecified language got the C locale, due to taking a short-cut that would make sense if no locale were found for a specified language. Stop assuming the language was specified. Task-number: QTBUG-74287 Change-Id: I8b3c232da584fb187ebb6c190729c377d0083808 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit e69b81101c6e09d1c1b81d50ea868a8625c9f248) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Deal with {und,ov}erflow issues in QLine's length handlingEdward Welbourne2020-10-272-18/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use std::hypot() instead of sqrt() of a sum of squares. This ensures length() can't be zero when isNull() is false. Use length() in QLine::setLength() rather than duplicating that. Clarify and expand some documentation; isNull() never said what constituted validity, nor did unitVector() mention that is should not be used on a line for which isNull() is true. Make clear that lines of denormal length cannot be rescaled accurately. Given that we use fuzzy comparison to determine equality of end-points, isNull() can be false for a line with displacements less than sqrt(numeric_limits<qreal>::denorm_min()) between the coordinates of its end-points (as long as these are not much bigger); squaring these would give zero, hence a zero length, where using hypot() avoids the underflow and gives a non-zero length. Having a zero length for a line with isNull() false would lead to problems in setLength(), which uses an isNull() pre-test, protecting a call to unitVector(). (It was already possible for a null line to have non-zero length; this now arises in more cases.) Reworked QLine::setLength() to allow for the possibility that the unit vector it computes as transient may not have length exactly one. Add tests against {ov,und}erflow and divide-by-zero problems in QLine. Picked version for 5.12 needed to adapt the test to simulate 5.15 and later's QCOMPARE(act, exp) effectively testing qFuzzyIsNull(exp) ? qFuzzyIsNull(act) : qFuzzyCompare(act, exp) where 5.12 just uses plain qFuzzyCompare(). Change-Id: I7b71d66b872ccc08a64e941acd36b45b0ea15fab Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> (cherry picked from commit 1c591fd9246ca776304a3c370dd2578bd886feac) Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix race in QFseventsFileSystemWatcher destructorErik Verbruggen2020-10-261-6/+8
| | | | | | | | | | | | | | | | | | | | | | | The race goes like this: 1) We destruct QFseventsFileSystemWatcher, which calls FSEventStreamStop and FSEventStreamInvalidate/FSEventStreamRelease 2) The FSEvent* calls will happen on the same thread as the destructor is being called on, which will be different to the thread that the FSEvent* events are popping out on. 3) So, there could be a case where we are in the middle of processing an event, but the QFseventsFileSystemWatcher has already died. The fix is to dispatch the stop/invalidate/release on the queue associated with the stream. Patch by Matt Galloway! Fixes: QTBUG-85594 Change-Id: Ie168bbe91e55c5559632b37bc008e11597e4fdaf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 6533d1a47309956e8acda90eb4c41d245e817c93) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QXmlStreamReader: Don't resize readBuffer to a size it already hasRobert Loehning2020-09-221-1/+2
| | | | | | | | | | | Resizing it to 0 will cause it to allocate memory. This will then cause append() to copy the data from the other string instead of using copy on write. Task-number: oss-fuzz-24347 Change-Id: I581bd109f9b973e1c70b7b41b1f610a2ad5725b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 3e3fdbe831f24365780383b3c45a3d53f23ba435)
* QDir: add note to docs about isAbsolutePath(":foo") returning trueAhmad Samir2020-09-201-1/+5
| | | | | | | | | | | | As can be seen in the _q_resolveEntryAndCreateLegacyEngine_recursive method in QFileSystemEngine, paths starting with ':' are treated as QResources, which means that from QFileInfo's POV they're "not relative", which is why QDir::isAbsolutePath would return true. Change-Id: I701d08ce43ea707bc34c928e39bea0b83597a4b6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 0da5726a43b21d1532720c8cd3c687cc2373cd2b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix crash on serializing default-constructed QTimeZoneEdward Welbourne2020-09-031-2/+11
| | | | | | | | | | | | | The serialization code neglected to check against null. Sinze zones are saved either by IANA ID or in our special OffsetFromUtc format, representing an invalid zone by a string that cannot possibly be a valid IANA ID will do. Fixes: QTBUG-86019 Change-Id: I6882026403d00f8b254aab34c645f1cf8f9fcc2d Reviewed-by: Taylor Braun-Jones <taylor@braun-jones.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 14f3f419b0864944d75283a850dc0ce141feaf0e)
* Handle simulator platforms when parsing LC_BUILD_VERSION load commandTor Arne Vestbø2020-08-191-5/+26
| | | | | | | | Task-number: QTBUG-85764 Change-Id: Ie46bee0937908e2dfedfa3532394dde015abf891 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3911be61602695ed65e33e54bee38ee8bcd92539) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Resolve SDK and deployment target OS from load commandTor Arne Vestbø2020-08-191-7/+25
| | | | | | | Change-Id: Icce79186645f173b7f9be8ee6da0abed25cf3da0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 4e74bb48234f41c9d6306c7a3cd6835c2cd42348) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtPrivate::isLatin1: fix SSE2 non-SSE4.1 codeThiago Macieira2020-08-171-20/+1
| | | | | | | | | | | | | The implementation was broken. The "high" in PUNPCKHBW's "unpack high data" means the high 64-bit of the 128-bit, not the high byte of a 16- bit word. This never worked. It always passed for me because I don't build non-SSE4.2 code (too old, no longer relevant). So just use the working version of simdTestMask. Change-Id: I35a1b4d0a19a43149daefffd16284542f0de3fa3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 9422b5ebc3592f4687650a84131e736219308b9f)
* QByteArray::toDouble: fix buffer overflow reads on fromRawData()Thiago Macieira2020-08-171-6/+25
| | | | | | | | | | | | | If Qt was not compiled with libdouble-conversion, sscanf() requires null-termination, which fromRawData() does not require. This could be fixed by making QByteArray pass a reallocated copy if it is operating on raw data, but fixing qt_asciiToDouble() means we catch all cases and we optimize for the common case of not-horribly-long strings. Fixes: QTBUG-85580 Change-Id: Iea47e0f8fc8b40378df7fffd16246f6163b01442 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit efd3c7bf2427c8237857e56ecd51b8da3ce43a6e)
* Add QOperatingSystemVersion support for macOS Big SurTor Arne Vestbø2020-08-055-0/+146
| | | | | | | | Change-Id: Ide57f675b20b08210f301da5177df45d008423c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 19d32f0a5fc8b12e03a84ab6e18845337fd3b70f) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Adapt to MSVC difference in behavior in initializing non-aggregatesThiago Macieira2020-06-291-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testcase: struct A { A() = default; constexpr A(int v) :i(v) {} int i; }; extern const A y[1] = {}; In our case, A = std::atomic<int> and y = shared_null. With GCC, ICC, and Clang that "y" variable is value-initialized at static initialization time, and no dynamic initialization code is generated. However, with MSVC, because A is not an aggregate, the default constructor isn't constexpr (it leaves A::i uninitialized) so "y" must be dynamically initialized. That leads to Static Initialization Order Fiasco. This seems to be a regression in the MSVC 2019 16.6 STL: https://github.com/microsoft/STL/issues/661 The solution is simple: call the constexpr constructor. Code is different in 6.0 so sending separately from 5.x. Fixes: QTBUG-71548 Task-number: QTBUG-59721 Change-Id: I3d4f433ff6e94fd390a9fffd161b4a7e8c1867b1 Reviewed-by: Kai Koehne <kai.koehne@qt.io> (cherry picked from commit b619f2a26ea2ab56e18a3f9a8b635f96fc479563) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLinkedListData: Move Q_CORE_EXPORT from class to shared_nullThiago Macieira2020-05-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes no difference for the IA-64 C++ ABI nor for MSVC until MSVC 2019 16.6. But it does with 16.6, where the std::atomic constructor becomes non-trivial, which makes QtPrivate::RefCount non-trivial, which makes QLinkedListData non-trivial. Before this change: User code \ Qt MSVC <=16.5 MSVC >=16.6 MSVC <=16.5 works works MSVC >=16.6 fails works With this change, they should all work. The list of symbols exported should not change either, so linking against a Qt compiled with MSVC <=16.5 should continue to work. [ChangeLog][MSVC] Fixed a compatibility issue found when linking code compiled with version 16.6 to a Qt compiled with 16.5. Fixes: QTBUG-81727 Change-Id: If79a52e476594446baccfffd15ee771397467f8b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> (cherry picked from commit 7af5619836cb3bd2eca87fd10b81674c9e201e76) Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* Fix crash when running QtCore: Stack is misaligned on x86-64Thiago Macieira2020-04-301-1/+5
| | | | | | | | | | | When our ELF entry point function is started by the kernel, the stack is aligned at 16 bytes. However, the stack is expected to be off by 8, due to a preceding CALL instruction which didn't exist. This cauases a crash further down as the compiler may generate aligned stack access. Change-Id: I1496b069cc534f1a838dfffd15c9dc4ef9e3869e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 932805807123833bb8f5ae9abda7e946f48d9f0c)
* Merge remote-tracking branch 'origin/5.12.8' into 5.12Qt Forward Merge Bot2020-04-142-2/+26
|\ | | | | | | Change-Id: I3c060326bf24f31dda0fd6dd9ebf278da4c2fe46
| * Fix build with macOS 10.15 and deployment 10.12André Klitzing2020-03-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | io/qfilesystemengine_unix.cpp:1420:9: error: 'futimens' is only available on macOS 10.13 or newer [-Werror,-Wunguarded-availability-new] if (futimens(fd, ts) == -1) { ^~~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/stat.h:396:9: note: 'futimens' has been marked as being introduced in macOS 10.13 here, but the deployment target is macOS 10.12.0 int futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); ^ io/qfilesystemengine_unix.cpp:1420:9: note: enclose 'futimens' in a __builtin_available check to silence this warning if (futimens(fd, ts) == -1) { ^~~~~~~~ Change-Id: Ib52adf7b1ec4f1057d8cb260a00da509429cfaed Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 2f030c2cf3fe368be217c0e0b157e050d1c27afc)
| * Add an expansion limit for entitiesLars Knoll2020-03-252-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recursively defined entities can easily exhaust all available memory. Limit entity expansion to a default of 4096 characters to avoid DoS attacks when a user loads untrusted content. [ChangeLog][QtCore][QXmlStream] QXmlStreamReader does now limit the expansion of entities to 4096 characters. Documents where a single entity expands to more characters than the limit are not considered well formed. The limit is there to avoid DoS attacks through recursively expanding entities when loading untrusted content. Qt 5.15 will add methods that allow changing that limit. Fixes: QTBUG-47417 Change-Id: I94387815d74fcf34783e136387ee57fac5ded0c9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit fd4be84d23a0db4186cb42e736a9de3af722c7f7) Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | CBOR support: prevent overflowing QByteArray's max allocationThiago Macieira2020-04-103-21/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QByteArray doesn't like it. Apply the same protection to QString, which we know uses the same backend but uses elements twice as big. That means it can contain slightly more than half as many elements, but exact half will suffice for our needs. Change-Id: Iaa63461109844e978376fffd15f9d4c7a9137856 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 783d574b932288b61f915b28d5b7b9c5a979f58e) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | QCborValue: apply a simple optimization to avoid unnecessary allocationsThiago Macieira2020-04-102-28/+29
| | | | | | | | | | | | | | | | | | | | | | If the map or array is known to be empty, we don't need to allocate a QCborContainerPrivate. Change-Id: Ief61acdfbe4d4b5ba1f0fffd15fe212b6a6e77c3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit f581b041199ba7c825fbffd9110727360d1f2668) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | QCborValue::fromCbor: Apply a recursion limit to decodingThiago Macieira2020-04-102-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A simple 16k file can produce deep enough recursion in Qt to cause stack overflow. So prevent that. I tested 4096 recursions just fine on my Linux system (8 MB stack), but decided 1024 was sufficient, as this code will also be run on embedded systems that could have smaller stacks. [ChangeLog][QtCore][QCborValue] fromCbor() now limits decoding to at most 1024 nested maps, arrays, and tags to prevent stack overflows. This should be sufficient for most uses of CBOR. An API to limit further or to relax the limit will be provided in 5.15. Meanwhile, if decoding more is required, QCborStreamReader can be used (note that each level of map and array allocates memory). Change-Id: Iaa63461109844e978376fffd15fa0fbefbf607a2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 02d595946faa7a21f6aa4109227f7e90db20ae7a) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | QCborValue: create a wrapper to set the QCborStreamReader error stateThiago Macieira2020-04-102-6/+12
| | | | | | | | | | | | | | | | | | | | The next commit will need to do so from outside QCborContainerPrivate, where QCborStreamReader::d can't be accessed (private). Change-Id: Iaa63461109844e978376fffd15fa0f6f04081bf2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit b7da66132bdd196c4f0b0e0fdf53f9e3b9a8bdaf) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Fix build with macOS 10.15 and deployment 10.12André Klitzing2020-03-261-1/+2
|/ | | | | | | | | | | | | | | io/qfilesystemengine_unix.cpp:1420:9: error: 'futimens' is only available on macOS 10.13 or newer [-Werror,-Wunguarded-availability-new] if (futimens(fd, ts) == -1) { ^~~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/stat.h:396:9: note: 'futimens' has been marked as being introduced in macOS 10.13 here, but the deployment target is macOS 10.12.0 int futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); ^ io/qfilesystemengine_unix.cpp:1420:9: note: enclose 'futimens' in a __builtin_available check to silence this warning if (futimens(fd, ts) == -1) { ^~~~~~~~ Change-Id: Ib52adf7b1ec4f1057d8cb260a00da509429cfaed Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace usage of std::result_of with decltypeMårten Nordheim2020-02-221-1/+1
| | | | | | | | | It's slated for removal in c++20 Fixes: QTBUG-82240 Change-Id: I7b35c151413b131ca49b2c09b6382efc3fc8ccb6 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit fb6acf08bbd7a68d027282251747620b942bd1d6)
* QXmlStreamReader: early return in case of malformed attributesGiuseppe D'Angelo2020-02-101-2/+5
| | | | | | | | | There's no point at keep raising errors after encountering the first malformed attribute. (cherry picked from commit 4d8a515a230ca9864a94830fd376a1d3ecbe6886) Change-Id: I1c5e8caf92b09c91ec8c37eb72c72f2f937013e6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLockFile: Disable flock() on QNXThiago Macieira2020-02-101-0/+6
| | | | | | | | | | | | | | | | It appears it's not implemented. [ChangeLog][QtCore][QLockFile] Suppressed the warning on QNX that said 'setNativeLocks failed: "Function not implemented"'. There is no difference in behavior: Qt will continue not to be able to apply an OS- level file lock, which means the lock could be accidentally stolen by buggy software. Correct software using QLockFile should not be affected. Fixes: QTBUG-81701 Change-Id: If79a52e476594446baccfffd15ee35bbac6c6e47 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 9ede07613dc5b7759f398d5a8839b2ffdb4675a2) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix build: disable the HWRNG in bootstrapped modeThiago Macieira2020-02-041-1/+1
| | | | | | | | | | | qmake build fails: qrandom.o: in function `QRandomGenerator::SystemGenerator::generate(unsigned int*, unsigned int*)': /home/tjmaciei/src/qt/qt5/qtbase/src/corelib/global/qrandom.cpp:333: undefined reference to `qRandomCpu(void*, long long)' Fixes: QTBUG-78937 Change-Id: Ib5d667bf77a740c28d2efffd15cb4236f765917c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 4f88e0bbd1c014adc6db7a37e4754446c4c8f529)
* Merge remote-tracking branch 'origin/5.12.7' into 5.12Qt Forward Merge Bot2020-01-311-1/+3
|\ | | | | | | Change-Id: Ie152ac565d56ca4ae29998ee034ba4b8b5b8e234
| * QLibrary/Unix: do not attempt to load a library relative to $PWDThiago Macieira2020-01-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I added the code in commit 5219c37f7c98f37f078fee00fe8ca35d83ff4f5d to find libraries in a haswell/ subdir of the main path, but we only need to do that transformation if the library is contains at least one directory seprator. That is, if the user asks to load "lib/foo", then we should try "lib/haswell/foo" (often, the path prefix will be absolute). When the library name the user requested has no directory separators, we let dlopen() do the transformation for us. Testing on Linux confirms glibc does so: $ LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 --inhibit-cache ./qml -help |& grep Xcursor 1972475: find library=libXcursor.so.1 [0]; searching 1972475: trying file=/usr/lib64/haswell/avx512_1/libXcursor.so.1 1972475: trying file=/usr/lib64/haswell/libXcursor.so.1 1972475: trying file=/usr/lib64/libXcursor.so.1 1972475: calling init: /usr/lib64/libXcursor.so.1 1972475: calling fini: /usr/lib64/libXcursor.so.1 [0] Fixes: QTBUG-81272 Change-Id: I596aec77785a4e4e84d5fffd15e89689bb91ffbb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit e6f1fde24f77f63fb16b2df239f82a89d2bf05dd) Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Fix qt5_make_output_file macro for paths containing dotsJoerg Bornemann2020-01-291-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 89bd5a7e broke CMake projects that use dots in their build paths, because the used regular expression matches the directory part of the path as well. The regex wants to achieve the same as get_filename_component(... NAME_WLE) which is available since CMake 3.14. Re-implement the NAME_WLE functionality for older CMake versions by using multiple get_filename_component calls. Fixes: QTBUG-81715 Task-number: QTBUG-80295 Change-Id: I2ef053300948f6e1b2c0c5eafac35105f193d4e6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Un-deprecate QSignalMapperSona Kurazyan2020-01-232-8/+4
|/ | | | | | | | | | | From the comments on QTBUG-73407 and the last comments on 29bcbeab90210da80234529905d17280374f9684, it seems like there are still use-cases when QSignalMapper is useful. Change-Id: I8402286cb8a395a4601cda8a4cdda51f19aef073 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit b6688a4d4939b15713ffd8702253433032879fcb)
* QObject: make the connectedSignals member use QAtomicIntegerThiago Macieira2020-01-152-6/+7
| | | | | | | | | | | | | | | The bitfield is always mutated under a mutex lock, so there's no need for atomic bit operations. This is needed because there's one outstanding access (in isSignalConnected()) that is done outside the mutex. Not needed in 5.14 because commit a5a859e721e7a1d0c5a3ec6abe2db55d9144bb36 removed the bit field altogether. Fixes: QTBUG-81376 Patch-By: Chris Thornton Change-Id: Idc3fae4d0f614c389d27fffd15ea1d372968f8f1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* ucstrncmp: Fix UBSan report of array overflowingThiago Macieira2020-01-111-4/+4
| | | | | | | | | | | | | | | | The expression "a + offset + N" will eventually calculate an address past the end of a, since we are comparing to end. That's undefined behavior. Instead, calculate end - a and compare that to offset + N. This commit subtracts "a" from both sides of the inequalities and swaps the two sides to make them obey Qt coding style. Testing with GCC 9 (which is the only one I care about) shows the compiler generates the same code. Fixes: QTBUG-81218 Change-Id: Id84da383373844f3a4b0fffd15e7c1ab904daccd Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> (cherry picked from commit 64359ad710756e7cca5ca553521b2aada18fb0fe)
* Replace get_filename_component usage with REGEX_REPLACEAlexey Edelev2019-11-271-1/+1
| | | | | | | | | | Replace get_filename_component usage with custom string REGEX_REPLACE to avoid cutting non-ending suffices while moc generation Fixes: QTBUG-80295 Change-Id: I8cdb729370c6d884f6638d172ee523fdc2df5404 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Do not load plugin from the $PWDOlivier Goffart2019-11-131-1/+0
| | | | | | | | | | I see no reason why this would make sense to look for plugins in the current directory. And when there are plugins there, it may actually be wrong Change-Id: I5f5aa168021fedddafce90effde0d5762cd0c4c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit bf131e8d2181b3404f5293546ed390999f760404) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix a -Wclass-memaccess problem in qjsonVille Voutilainen2019-10-281-1/+3
| | | | | | | | | | qtbase/src/corelib/serialization/qjson_p.h:230:38: error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of type ‘QJsonPrivate::qle_ushort’ {aka ‘class QSpecialInteger<QLittleEndianStorageType<short unsigned int> >’} with ‘private’ member ‘QSpecialInteger<QLittleEndianStorageType<short unsigned int> >::val’ from an array of ‘const class QChar’; use assignment or copy-initialization instead [-Werror=class-memaccess] 230 | str.length()*sizeof(ushort)); | ^ Change-Id: Ie58e7fe4bae3003227364012ad56ab23bd560d8c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> (cherry picked from commit 9367d966e6c10c95b92f2b55e2cead7e85d80cfe)
* Windows/MinGW: Fix posted events timer not stoppingFriedemann Kleint2019-10-242-3/+7
| | | | | | | | | | | Specify the type of the enum value SendPostedEventsWindowsTimerId to be UINT_PTR to work with the g++ interpretation of enumeration signedness and use the correct type for the returned timer id. Fixes: QTBUG-78491 Change-Id: I7b3f306d3f60da7a21500ece5243ac90854ccf1a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d35de9e1b250ce46739dcb6afb9ae8a0247195c7)
* Fix for compilers that don't allow casting nullptr_t to an integerVolker Hilsheimer2019-10-141-1/+2
| | | | | | | | | | Visual Studio 14.0 toolchain at least seems to be broken enough to somehow interpret the cast from nullptr to a quintptr as being ill-formed, inspite of it being valid C++. Change-Id: Ifb29be3af82764cb31fa65409f7e1000ea419498 Fixes: QTBUG-79080 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Include likely-adjusted uiLanguages for the system localeEdward Welbourne2019-10-102-16/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QLocale::uiLanguages() on the system locale uses whatever the system locale's query(QSystemLocale::UILanguages,...) returns. On Android, this is just a list of locales. However, for non-system locales, we also include some results of removing likely sub-tags from the locale name, where equivalent. Thus zh-CN would also get zh and zh-Hans-CN added to it; however, if the system locale is zh-Hans-CN, the shorter forms are omitted. So post-process the system locale list in the same way, albeit tweaked to avoid duplicates and rearranged so that we can insert likely-adjusted entries between what they adjust and what followed it. Added QLocalePrivate::rawName() in the process, since it looks likely to be useful in other contexts (and I needed its value): it just joins such tags as are non-Any. This, however, uses QByteArrayList, so added that (it's small) to the bootstrap library and qmake. This follows up on commit 8796e3016fae1672e727e2fa4e48f671a0c667ba. [ChangeLog][QtCore][QLocale] The system locale's UI languages list now includes, as for that of an ordinary locale, the results of adding likely sub-tags from each locale name, and of removing some, where this doesn't change which locale is specified. This gives searches for translation files a better chance of finding a suitable file. Fixes: QTBUG-75413 Change-Id: Iaafd79aac6a0fdd5f44aed16e445e84a2267c9da Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 0118e2e9151ae3e1e1cd72f24e8c129eaa69dc4f)
* Filesystem: avoid crashes on exit in case the locale codec is nullThiago Macieira2019-10-091-1/+3
| | | | | | | | | | | | | | | | | | | | On exit, QLocale::codecForLocale() can return null as the codec may have already been destroyed. In that case, pretend that Latin1 was the locale, so any file name is acceptable. This matches QString: QTextCodec *codec = QTextCodec::codecForLocale(); if (codec) return codec->toUnicode(str, size); #endif // textcodec return fromLatin1(str, size); Note that if we're wrong and the locale was *not* Latin1, files that you had a name to may not be encoded or decoded the same way. Fixes: QTBUG-78446 Change-Id: Iece6e011237e4ab284ecfffd15c54077728a17ca Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 70e6e9fe590590f602dee230a64870365d9301aa)
* Fix QRandomGenerator initialization on AMD CPUsDmitry Kazakov2019-10-084-46/+88
| | | | | | | | | | | | | | | | Some AMD CPUs (e.g. AMD A4-6250J and AMD Ryzen 3000-series) have a failing random generation instruction, which always returns 0xffffffff, even when generation was "successful". This code checks if hardware random generator generates four consecutive equal numbers. If it does, then we probably have a failing one and should disable it completely. Change-Id: I38c87920ca2e8cce4143afbff5e453ce3845d11a Fixes: QTBUG-69423 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 5839714d986f28412c9f9ed4801d1bf9378f7b51) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc-fix: correct some misinformation about QDateTime's handling of DSTEdward Welbourne2019-09-191-23/+30
| | | | | | | | | | | | | | | | | Tidy up QDateTime::offsetFromUtc's doc, in the process. We don't take DST into account for dates before the epoch; that should be mentioned when saying we take DST into account. Also, referring to *this as the "current" time begs to be misunderstood. The \class comment also misleadingly claimed that we don't take into account any changes to time-zone before DST; where, in fact, we only ignore DST changes before 1970, not changes to standard offset. (Conflict resolution also pulled in a typo-fix from 5.14.) Change-Id: I090e668edf0338c825f5afcc67f894579a129c46 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit c6bde29e143b1fadac97f656ba6c3059135d4a11) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* MS TZ data: avoid calculating a date in year 0Edward Welbourne2019-09-191-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | There is no year 0 in the proleptic Gregorian calendar, so QDate() won't be happy if asked for a date in it. Tweak scanning of the data we get from MS-Win so as to avoid a date calculation that could otherwise happen in year 0 when constructing QDateTime(QDate(1, 1, 1), QTime(0, 0, 0), QTimeZone("Australia/Sydney")). Added a test for this case, which Oliver Wolff has kindly verified does reproduce the assertion failure. However, Coin is unable to reproduce, as all its MS builds are configured with -release, so Q_ASSERT() does nothing. (The relevant code then skips over year 0, albeit for the wrong reasons, and gets the right results, albeit inefficiently, leaving no other symptom by which to detect the problem.) Fixes: QTBUG-78051 Change-Id: Ife8a7470e5bd450bc421e89b3f1e1211756fc889 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 8286daba038d3c90d2bc06785ffcf9c0c603cb83) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qFatal: make it so you cannot disable the messageThiago Macieira2019-09-041-2/+2
| | | | | | | | | | Solves a few recursion problems in Qt, since then we won't try to inspect the logging registry while creating the logging registry. Fixes: QTBUG-78007 Change-Id: I44cc9ee732f54d2380bafffd15c0f51c7140682e Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>