diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-08-27 15:25:26 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-08-30 17:46:00 +0200 |
commit | 7d33779a795afb54af1a96c0da93b532f9db3ba2 (patch) | |
tree | a760a2777d752fba7f91135ae7b80d37750d5745 /src/corelib/time | |
parent | 5644af6f8a800a1516360a42ba4c1a8dc61fc516 (diff) |
Convert various callers of strtou?ll() to call strntou?ll()
Where size is known or can readily be determined.
Change-Id: I442e7ebb3757fdbf7d021a15e19aeba533b590a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/time')
-rw-r--r-- | src/corelib/time/qtimezoneprivate_tz.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index 96399b029f..c27820ca6e 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -419,23 +419,17 @@ static int parsePosixTime(const char *begin, const char *end) // Format "hh[:mm[:ss]]" int hour, min = 0, sec = 0; - // Note that the calls to qstrtoll do *not* check against the end pointer, - // which means they proceed until they find a non-digit. We check that we're - // still in range at the end, but we may have read past end. It's the - // caller's responsibility to ensure that begin is part of a null-terminated - // string. - const int maxHour = 137; // POSIX's extended range. bool ok = false; const char *cut = begin; - hour = qstrtoll(begin, &cut, 10, &ok); + hour = qstrntoll(begin, end - begin, &cut, 10, &ok); if (!ok || hour < -maxHour || hour > maxHour || cut > begin + 2) return INT_MIN; begin = cut; if (begin < end && *begin == ':') { // minutes ++begin; - min = qstrtoll(begin, &cut, 10, &ok); + min = qstrntoll(begin, end - begin, &cut, 10, &ok); if (!ok || min < 0 || min > 59 || cut > begin + 2) return INT_MIN; @@ -443,7 +437,7 @@ static int parsePosixTime(const char *begin, const char *end) if (begin < end && *begin == ':') { // seconds ++begin; - sec = qstrtoll(begin, &cut, 10, &ok); + sec = qstrntoll(begin, end - begin, &cut, 10, &ok); if (!ok || sec < 0 || sec > 59 || cut > begin + 2) return INT_MIN; begin = cut; |