Changeset 172725 in webkit


Ignore:
Timestamp:
Aug 18, 2014 2:14:35 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Fix unintentional integer overflow before widen
https://bugs.webkit.org/show_bug.cgi?id=135463

Patch by Przemyslaw Kuczynski <p.kuczynski@samsung.com> on 2014-08-18
Reviewed by Oliver Hunt.

Overflowing expression is evaluated using operands arithmetic but then is used in
context which expects an wider integer type. To avoid overflow at least one operand
has to be representative of the wider type.

Source/WebCore:

  • loader/FTPDirectoryParser.cpp:

(WebCore::parseOneFTPLine): Changed strtoul to strtoull.

  • loader/ProgressTracker.cpp:

(WebCore::ProgressTracker::incrementProgress): Added static_cast to long long.

  • platform/efl/FileSystemEfl.cpp:

(WebCore::getVolumeFreeSizeForPath): Added static_cast to uint64_t.

Source/WebKit2:

  • WebProcess/soup/WebProcessSoup.cpp:

(WebKit::getMemorySize): Added long long literal.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r172723 r172725  
     12014-08-18  Przemyslaw Kuczynski  <p.kuczynski@samsung.com>
     2
     3        Fix unintentional integer overflow before widen
     4        https://bugs.webkit.org/show_bug.cgi?id=135463
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Overflowing expression is evaluated using operands arithmetic but then is used in
     9        context which expects an wider integer type. To avoid overflow at least one operand
     10        has to be representative of the wider type.
     11
     12        * loader/FTPDirectoryParser.cpp:
     13        (WebCore::parseOneFTPLine): Changed strtoul to strtoull.
     14        * loader/ProgressTracker.cpp:
     15        (WebCore::ProgressTracker::incrementProgress): Added static_cast to long long.
     16        * platform/efl/FileSystemEfl.cpp:
     17        (WebCore::getVolumeFreeSizeForPath): Added static_cast to uint64_t.
     18
    1192014-08-18  Vivek Galatage  <vivek.vg@samsung.com>
    220
  • trunk/Source/WebCore/loader/FTPDirectoryParser.cpp

    r160671 r172725  
    506506               * than not showing the size at all.
    507507              */
    508               uint64_t size = strtoul(tokens[1], NULL, 10) * 512;
     508              uint64_t size = strtoull(tokens[1], 0, 10) * 512;
    509509              result.fileSize = String::number(size);
    510510            }
  • trunk/Source/WebCore/loader/ProgressTracker.cpp

    r170464 r172725  
    235235   
    236236    int numPendingOrLoadingRequests = frame->loader().numPendingOrLoadingRequests(true);
    237     estimatedBytesForPendingRequests = progressItemDefaultEstimatedLength * numPendingOrLoadingRequests;
     237    estimatedBytesForPendingRequests = static_cast<long long>(progressItemDefaultEstimatedLength) * numPendingOrLoadingRequests;
    238238    remainingBytes = ((m_totalPageAndResourceBytesToLoad + estimatedBytesForPendingRequests) - m_totalBytesReceived);
    239239    if (remainingBytes > 0)  // Prevent divide by 0.
  • trunk/Source/WebCore/platform/efl/FileSystemEfl.cpp

    r165676 r172725  
    106106        return 0;
    107107
    108     return buf.f_bavail * buf.f_bsize;
     108    return static_cast<uint64_t>(buf.f_bavail) * buf.f_bsize;
    109109}
    110110
  • trunk/Source/WebKit2/ChangeLog

    r172724 r172725  
     12014-08-18  Przemyslaw Kuczynski  <p.kuczynski@samsung.com>
     2
     3        Fix unintentional integer overflow before widen
     4        https://bugs.webkit.org/show_bug.cgi?id=135463
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Overflowing expression is evaluated using operands arithmetic but then is used in
     9        context which expects an wider integer type. To avoid overflow at least one operand
     10        has to be representative of the wider type.
     11
     12        * WebProcess/soup/WebProcessSoup.cpp:
     13        (WebKit::getMemorySize): Added long long literal.
     14
    1152014-08-18  Przemyslaw Kuczynski  <p.kuczynski@samsung.com>
    216
  • trunk/Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp

    r169550 r172725  
    7575        return kDefaultMemorySize;
    7676
    77     return ((pageSize / 1024) * physPages) / 1024;
     77    return ((pageSize / 1024LL) * physPages) / 1024LL;
    7878#else
    7979    // Fallback to default for other platforms.
Note: See TracChangeset for help on using the changeset viewer.