Use unsigned consistently, and check for invalid casts when calling into SharedBuffer...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jan 2014 11:17:46 +0000 (11:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jan 2014 11:17:46 +0000 (11:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124579

Patch by László Langó <lango@inf.u-szeged.hu> on 2014-01-06
Reviewed by Anders Carlsson.

Source/WebCore:

* WebCore.exp.in:
* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::didReceiveData):
* loader/NetscapePlugInStreamLoader.h:
* loader/PingLoader.h:
* loader/ResourceBuffer.cpp:
(WebCore::ResourceBuffer::ResourceBuffer):
* loader/ResourceBuffer.h:
(WebCore::ResourceBuffer::create):
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::addDataOrBuffer):
(WebCore::ResourceLoader::didReceiveData):
(WebCore::ResourceLoader::didReceiveDataOrBuffer):
(WebCore::ResourceLoader::willStopBufferingData):
* loader/ResourceLoader.h:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didReceiveData):
* loader/SubresourceLoader.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didReceiveData):
* loader/appcache/ApplicationCacheGroup.h:
* loader/mac/ResourceLoaderMac.mm:
(WebCore::ResourceLoader::didReceiveDataArray):
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::SharedBuffer):
* platform/SharedBuffer.h:
(WebCore::SharedBuffer::create):
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(ResourceHandleStreamingClient::didReceiveData):
* platform/network/BlobResourceHandle.cpp:
* platform/network/ResourceHandleClient.h:
(WebCore::ResourceHandleClient::didReceiveData):
(WebCore::ResourceHandleClient::willStopBufferingData):
* platform/network/SynchronousLoaderClient.cpp:
(WebCore::SynchronousLoaderClient::didReceiveData):
* platform/network/SynchronousLoaderClient.h:
* platform/network/blackberry/BlobStream.cpp:
(WebCore::BlobStream::didReceiveData):
* platform/network/blackberry/BlobStream.h:
* platform/network/blackberry/ResourceHandleBlackBerry.cpp:
(WebCore::WebCoreSynchronousLoader::didReceiveData):
* platform/network/curl/ResourceHandleCurl.cpp:
(WebCore::WebCoreSynchronousLoader::didReceiveData):
* platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
(-[WebCoreResourceHandleAsDelegate connection:willStopBufferingData:]):
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willStopBufferingData:]):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::WebCoreSynchronousLoader::didReceiveData):
* platform/network/win/ResourceHandleWin.cpp:
(WebCore::WebCoreSynchronousLoader::didReceiveData):

Source/WebKit/gtk:

* webkit/webkitdownload.cpp:
(DownloadClient::didReceiveData):

Source/WebKit/win:

* WebKitDLL.cpp:
(loadResourceIntoBuffer):

Source/WebKit2:

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveData):
(WebKit::NetworkResourceLoader::willStopBufferingData):
* NetworkProcess/NetworkResourceLoader.h:
* Shared/Downloads/soup/DownloadSoup.cpp:
(WebKit::DownloadClient::didReceiveData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161338 268f45cc-cd09-0410-ab3c-d52691b4dbfc

37 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/loader/NetscapePlugInStreamLoader.cpp
Source/WebCore/loader/NetscapePlugInStreamLoader.h
Source/WebCore/loader/PingLoader.h
Source/WebCore/loader/ResourceBuffer.cpp
Source/WebCore/loader/ResourceBuffer.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoader.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/SubresourceLoader.h
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/appcache/ApplicationCacheGroup.h
Source/WebCore/loader/mac/ResourceLoaderMac.mm
Source/WebCore/platform/SharedBuffer.cpp
Source/WebCore/platform/SharedBuffer.h
Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
Source/WebCore/platform/network/BlobResourceHandle.cpp
Source/WebCore/platform/network/ResourceHandleClient.h
Source/WebCore/platform/network/SynchronousLoaderClient.cpp
Source/WebCore/platform/network/SynchronousLoaderClient.h
Source/WebCore/platform/network/blackberry/BlobStream.cpp
Source/WebCore/platform/network/blackberry/BlobStream.h
Source/WebCore/platform/network/blackberry/ResourceHandleBlackBerry.cpp
Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp
Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm
Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/platform/network/win/ResourceHandleWin.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitdownload.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKitDLL.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp

index d50ae94..a5c7391 100644 (file)
@@ -1,3 +1,62 @@
+2014-01-06  László Langó  <lango@inf.u-szeged.hu>
+
+        Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
+        https://bugs.webkit.org/show_bug.cgi?id=124579
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in:
+        * loader/NetscapePlugInStreamLoader.cpp:
+        (WebCore::NetscapePlugInStreamLoader::didReceiveData):
+        * loader/NetscapePlugInStreamLoader.h:
+        * loader/PingLoader.h:
+        * loader/ResourceBuffer.cpp:
+        (WebCore::ResourceBuffer::ResourceBuffer):
+        * loader/ResourceBuffer.h:
+        (WebCore::ResourceBuffer::create):
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::addDataOrBuffer):
+        (WebCore::ResourceLoader::didReceiveData):
+        (WebCore::ResourceLoader::didReceiveDataOrBuffer):
+        (WebCore::ResourceLoader::willStopBufferingData):
+        * loader/ResourceLoader.h:
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::didReceiveData):
+        * loader/SubresourceLoader.h:
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::didReceiveData):
+        * loader/appcache/ApplicationCacheGroup.h:
+        * loader/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::didReceiveDataArray):
+        * platform/SharedBuffer.cpp:
+        (WebCore::SharedBuffer::SharedBuffer):
+        * platform/SharedBuffer.h:
+        (WebCore::SharedBuffer::create):
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (ResourceHandleStreamingClient::didReceiveData):
+        * platform/network/BlobResourceHandle.cpp:
+        * platform/network/ResourceHandleClient.h:
+        (WebCore::ResourceHandleClient::didReceiveData):
+        (WebCore::ResourceHandleClient::willStopBufferingData):
+        * platform/network/SynchronousLoaderClient.cpp:
+        (WebCore::SynchronousLoaderClient::didReceiveData):
+        * platform/network/SynchronousLoaderClient.h:
+        * platform/network/blackberry/BlobStream.cpp:
+        (WebCore::BlobStream::didReceiveData):
+        * platform/network/blackberry/BlobStream.h:
+        * platform/network/blackberry/ResourceHandleBlackBerry.cpp:
+        (WebCore::WebCoreSynchronousLoader::didReceiveData):
+        * platform/network/curl/ResourceHandleCurl.cpp:
+        (WebCore::WebCoreSynchronousLoader::didReceiveData):
+        * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
+        (-[WebCoreResourceHandleAsDelegate connection:willStopBufferingData:]):
+        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willStopBufferingData:]):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::WebCoreSynchronousLoader::didReceiveData):
+        * platform/network/win/ResourceHandleWin.cpp:
+        (WebCore::WebCoreSynchronousLoader::didReceiveData):
+
 2014-01-06  Andreas Kling  <akling@apple.com>
 
         RenderBlock::clone() should return RenderPtr.
index 4fd3650..0092915 100644 (file)
@@ -233,8 +233,8 @@ __ZN7WebCore12SharedBuffer12createCFDataEv
 __ZN7WebCore12SharedBuffer12createNSDataEv
 __ZN7WebCore12SharedBuffer24createWithContentsOfFileERKN3WTF6StringE
 __ZN7WebCore12SharedBuffer6appendEPKcj
-__ZN7WebCore12SharedBufferC1EPKci
-__ZN7WebCore12SharedBufferC1EPKhi
+__ZN7WebCore12SharedBufferC1EPKcj
+__ZN7WebCore12SharedBufferC1EPKhj
 __ZN7WebCore12SharedBufferC1Ev
 __ZN7WebCore12SharedBufferD1Ev
 __ZN7WebCore12TextEncodingC1ERKN3WTF6StringE
@@ -354,7 +354,7 @@ __ZN7WebCore14LoaderStrategy25loadResourceSynchronouslyEPNS_17NetworkingContextE
 __ZN7WebCore14PluginDocument12pluginWidgetEv
 __ZN7WebCore14ResourceBuffer12createNSDataEv
 __ZN7WebCore14ResourceBuffer6appendEPKcj
-__ZN7WebCore14ResourceBufferC1EPKci
+__ZN7WebCore14ResourceBufferC1EPKcj
 __ZN7WebCore14ResourceBufferC1Ev
 __ZN7WebCore14ResourceBufferC2Ev
 __ZN7WebCore14ResourceBufferD1Ev
index 7a7cf36..b8c4556 100644 (file)
@@ -94,7 +94,7 @@ void NetscapePlugInStreamLoader::didReceiveResponse(const ResourceResponse& resp
         cancel(frameLoader()->client().fileDoesNotExistError(response));
 }
 
-void NetscapePlugInStreamLoader::didReceiveData(const char* data, int length, long long encodedDataLength, DataPayloadType dataPayloadType)
+void NetscapePlugInStreamLoader::didReceiveData(const char* data, unsigned length, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     didReceiveDataOrBuffer(data, length, 0, encodedDataLength, dataPayloadType);
 }
index c13e888..608925a 100644 (file)
@@ -57,7 +57,7 @@ public:
 
 private:
     virtual void didReceiveResponse(const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(const char*, int, long long encodedDataLength, DataPayloadType) OVERRIDE;
+    virtual void didReceiveData(const char*, unsigned, long long encodedDataLength, DataPayloadType) OVERRIDE;
     virtual void didReceiveBuffer(PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType) OVERRIDE;
     virtual void didFinishLoading(double finishTime) OVERRIDE;
     virtual void didFail(const ResourceError&) OVERRIDE;
index b8ac141..358d635 100644 (file)
@@ -65,7 +65,7 @@ private:
     PingLoader(Frame*, ResourceRequest&);
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE { delete this; }
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int) OVERRIDE { delete this; }
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int) OVERRIDE { delete this; }
     virtual void didFinishLoading(ResourceHandle*, double) OVERRIDE { delete this; }
     virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE { delete this; }
     virtual bool shouldUseCredentialStorage(ResourceHandle*)  OVERRIDE { return m_shouldUseCredentialStorage; }
index 06e3879..38afaa4 100644 (file)
@@ -35,7 +35,7 @@ ResourceBuffer::ResourceBuffer()
 {
 }
 
-ResourceBuffer::ResourceBuffer(const char* data, int size)
+ResourceBuffer::ResourceBuffer(const char* data, unsigned size)
     : m_sharedBuffer(SharedBuffer::create(data, size))
 {
 }
index 5e915b7..cd6cb6c 100644 (file)
@@ -45,7 +45,7 @@ class ResourceBuffer : public RefCounted<ResourceBuffer> {
 public:
 
     static PassRefPtr<ResourceBuffer> create() { return adoptRef(new ResourceBuffer); }
-    static PassRefPtr<ResourceBuffer> create(const char* data, int size) { return adoptRef(new ResourceBuffer(data, size)); }
+    static PassRefPtr<ResourceBuffer> create(const char* data, unsigned size) { return adoptRef(new ResourceBuffer(data, size)); }
     static PassRefPtr<ResourceBuffer> adoptSharedBuffer(PassRefPtr<SharedBuffer> shared) { return shared ? adoptRef(new ResourceBuffer(shared)) : 0; }
 
     virtual ~ResourceBuffer();
@@ -94,7 +94,7 @@ protected:
     ResourceBuffer();
 
 private:
-    ResourceBuffer(const char*, int);
+    ResourceBuffer(const char*, unsigned);
     ResourceBuffer(PassRefPtr<SharedBuffer>);
 
     RefPtr<SharedBuffer> m_sharedBuffer;
index ddd25b7..ebef76f 100644 (file)
@@ -206,7 +206,7 @@ void ResourceLoader::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPol
 }
     
 
-void ResourceLoader::addDataOrBuffer(const char* data, int length, SharedBuffer* buffer, DataPayloadType dataPayloadType)
+void ResourceLoader::addDataOrBuffer(const char* data, unsigned length, SharedBuffer* buffer, DataPayloadType dataPayloadType)
 {
     if (m_options.dataBufferingPolicy == DoNotBufferData)
         return;
@@ -307,7 +307,7 @@ void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
         frameLoader()->notifier().didReceiveResponse(this, m_response);
 }
 
-void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, DataPayloadType dataPayloadType)
+void ResourceLoader::didReceiveData(const char* data, unsigned length, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     // The following assertions are not quite valid here, since a subclass
     // might override didReceiveData in a way that invalidates them. This
@@ -323,7 +323,7 @@ void ResourceLoader::didReceiveBuffer(PassRefPtr<SharedBuffer> buffer, long long
     didReceiveDataOrBuffer(0, 0, buffer, encodedDataLength, dataPayloadType);
 }
 
-void ResourceLoader::didReceiveDataOrBuffer(const char* data, int length, PassRefPtr<SharedBuffer> prpBuffer, long long encodedDataLength, DataPayloadType dataPayloadType)
+void ResourceLoader::didReceiveDataOrBuffer(const char* data, unsigned length, PassRefPtr<SharedBuffer> prpBuffer, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     // This method should only get data+length *OR* a SharedBuffer.
     ASSERT(!prpBuffer || (!data && !length));
@@ -342,7 +342,7 @@ void ResourceLoader::didReceiveDataOrBuffer(const char* data, int length, PassRe
         frameLoader()->notifier().didReceiveData(this, buffer ? buffer->data() : data, buffer ? buffer->size() : length, static_cast<int>(encodedDataLength));
 }
 
-void ResourceLoader::willStopBufferingData(const char* data, int length)
+void ResourceLoader::willStopBufferingData(const char* data, unsigned length)
 {
     if (m_options.dataBufferingPolicy == DoNotBufferData)
         return;
@@ -498,7 +498,7 @@ void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
     didReceiveResponse(response);
 }
 
-void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
+void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, unsigned length, int encodedDataLength)
 {
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier(), encodedDataLength);
     didReceiveData(data, length, encodedDataLength, DataPayloadBytes);
index 6dd9eb6..4fc9b3a 100644 (file)
@@ -92,9 +92,9 @@ public:
     virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
     virtual void didReceiveResponse(const ResourceResponse&);
-    virtual void didReceiveData(const char*, int, long long encodedDataLength, DataPayloadType);
+    virtual void didReceiveData(const char*, unsigned, long long encodedDataLength, DataPayloadType);
     virtual void didReceiveBuffer(PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
-    void willStopBufferingData(const char*, int);
+    void willStopBufferingData(const char*, unsigned);
     virtual void didFinishLoading(double finishTime);
     virtual void didFail(const ResourceError&);
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
@@ -114,14 +114,14 @@ public:
     virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse) OVERRIDE;
     virtual void didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int encodedDataLength) OVERRIDE;
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int encodedDataLength) OVERRIDE;
     virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedDataLength) OVERRIDE;
     virtual void didFinishLoading(ResourceHandle*, double finishTime) OVERRIDE;
     virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
     virtual void wasBlocked(ResourceHandle*) OVERRIDE;
     virtual void cannotShowURL(ResourceHandle*) OVERRIDE;
 #if PLATFORM(MAC)
-    virtual void willStopBufferingData(ResourceHandle*, const char* data, int length) OVERRIDE { willStopBufferingData(data, length); }
+    virtual void willStopBufferingData(ResourceHandle*, const char* data, unsigned length) OVERRIDE { willStopBufferingData(data, length); }
 #endif
     virtual bool shouldUseCredentialStorage(ResourceHandle*) OVERRIDE { return shouldUseCredentialStorage(); }
     virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) OVERRIDE { didReceiveAuthenticationChallenge(challenge); } 
@@ -171,7 +171,7 @@ protected:
 
     bool wasCancelled() const { return m_cancellationStatus >= Cancelled; }
 
-    void didReceiveDataOrBuffer(const char*, int, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
+    void didReceiveDataOrBuffer(const char*, unsigned, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
 
     const ResourceLoaderOptions& options() { return m_options; }
 
@@ -184,7 +184,7 @@ private:
     virtual void willCancel(const ResourceError&) = 0;
     virtual void didCancel(const ResourceError&) = 0;
 
-    void addDataOrBuffer(const char*, int, SharedBuffer*, DataPayloadType);
+    void addDataOrBuffer(const char*, unsigned, SharedBuffer*, DataPayloadType);
 
     ResourceRequest m_request;
     ResourceRequest m_originalRequest; // Before redirects.
index d15d613..0f17264 100644 (file)
@@ -245,7 +245,7 @@ void SubresourceLoader::didReceiveResponse(const ResourceResponse& response)
     checkForHTTPStatusCodeError();
 }
 
-void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, DataPayloadType dataPayloadType)
+void SubresourceLoader::didReceiveData(const char* data, unsigned length, long long encodedDataLength, DataPayloadType dataPayloadType)
 {
     didReceiveDataOrBuffer(data, length, 0, encodedDataLength, dataPayloadType);
 }
index ed92f1c..89f4f29 100644 (file)
@@ -67,7 +67,7 @@ private:
     virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse) OVERRIDE;
     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
     virtual void didReceiveResponse(const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(const char*, int, long long encodedDataLength, DataPayloadType) OVERRIDE;
+    virtual void didReceiveData(const char*, unsigned, long long encodedDataLength, DataPayloadType) OVERRIDE;
     virtual void didReceiveBuffer(PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType) OVERRIDE;
     virtual void didFinishLoading(double finishTime) OVERRIDE;
     virtual void didFail(const ResourceError&) OVERRIDE;
index 7357b45..5ba9f62 100644 (file)
@@ -595,7 +595,7 @@ void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
     m_currentResource = ApplicationCacheResource::create(url, response, type);
 }
 
-void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* data, int length, int encodedDataLength)
+void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* data, unsigned length, int encodedDataLength)
 {
     UNUSED_PARAM(encodedDataLength);
 
index a501673..4516d2d 100644 (file)
@@ -110,7 +110,7 @@ private:
     virtual bool shouldUseCredentialStorage(ResourceHandle*) OVERRIDE { return true; }
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(ResourceHandle*, const char*, int length, int encodedDataLength) OVERRIDE;
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned length, int encodedDataLength) OVERRIDE;
     virtual void didFinishLoading(ResourceHandle*, double finishTime) OVERRIDE;
     virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
 
index 24d8950..1ef88d4 100644 (file)
@@ -79,7 +79,7 @@ void ResourceLoader::didReceiveDataArray(CFArrayRef dataArray)
     CFIndex arrayCount = CFArrayGetCount(dataArray);
     for (CFIndex i = 0; i < arrayCount; ++i) {
         CFDataRef data = static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, i));
-        int dataLen = static_cast<int>(CFDataGetLength(data));
+        unsigned dataLen = static_cast<unsigned>(CFDataGetLength(data));
 
         if (m_options.dataBufferingPolicy == BufferData) {
             if (!m_resourceData)
index f8152f2..db823cd 100644 (file)
@@ -75,7 +75,7 @@ SharedBuffer::SharedBuffer()
 {
 }
 
-SharedBuffer::SharedBuffer(size_t size)
+SharedBuffer::SharedBuffer(unsigned size)
     : m_size(size)
     , m_buffer(size)
 #if ENABLE(DISK_IMAGE_CACHE)
@@ -87,7 +87,7 @@ SharedBuffer::SharedBuffer(size_t size)
 {
 }
 
-SharedBuffer::SharedBuffer(const char* data, int size)
+SharedBuffer::SharedBuffer(const char* data, unsigned size)
     : m_size(0)
 #if ENABLE(DISK_IMAGE_CACHE)
     , m_isMemoryMapped(false)
@@ -96,14 +96,10 @@ SharedBuffer::SharedBuffer(const char* data, int size)
     , m_notifyMemoryMappedCallbackData(nullptr)
 #endif
 {
-    // FIXME: Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
-    if (size < 0)
-        CRASH();
-
     append(data, size);
 }
 
-SharedBuffer::SharedBuffer(const unsigned char* data, int size)
+SharedBuffer::SharedBuffer(const unsigned char* data, unsigned size)
     : m_size(0)
 #if ENABLE(DISK_IMAGE_CACHE)
     , m_isMemoryMapped(false)
@@ -112,10 +108,6 @@ SharedBuffer::SharedBuffer(const unsigned char* data, int size)
     , m_notifyMemoryMappedCallbackData(nullptr)
 #endif
 {
-    // FIXME: Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
-    if (size < 0)
-        CRASH();
-
     append(reinterpret_cast<const char*>(data), size);
 }
     
index 49cd192..82718b3 100644 (file)
@@ -52,9 +52,9 @@ class PurgeableBuffer;
 class SharedBuffer : public RefCounted<SharedBuffer> {
 public:
     static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer); }
-    static PassRefPtr<SharedBuffer> create(size_t size) { return adoptRef(new SharedBuffer(size)); }
-    static PassRefPtr<SharedBuffer> create(const char* c, int i) { return adoptRef(new SharedBuffer(c, i)); }
-    static PassRefPtr<SharedBuffer> create(const unsigned char* c, int i) { return adoptRef(new SharedBuffer(c, i)); }
+    static PassRefPtr<SharedBuffer> create(unsigned size) { return adoptRef(new SharedBuffer(size)); }
+    static PassRefPtr<SharedBuffer> create(const char* c, unsigned i) { return adoptRef(new SharedBuffer(c, i)); }
+    static PassRefPtr<SharedBuffer> create(const unsigned char* c, unsigned i) { return adoptRef(new SharedBuffer(c, i)); }
 
     static PassRefPtr<SharedBuffer> createWithContentsOfFile(const String& filePath);
 
@@ -168,9 +168,9 @@ public:
 
 private:
     SharedBuffer();
-    explicit SharedBuffer(size_t);
-    SharedBuffer(const char*, int);
-    SharedBuffer(const unsigned char*, int);
+    explicit SharedBuffer(unsigned);
+    SharedBuffer(const char*, unsigned);
+    SharedBuffer(const unsigned char*, unsigned);
     
     // Calling this function will force internal segmented buffers
     // to be merged into a flat buffer. Use getSomeData() whenever possible
index 2a7bbff..3aee48c 100644 (file)
@@ -99,7 +99,7 @@ class ResourceHandleStreamingClient : public ResourceHandleClient, public Stream
         virtual char* getOrCreateReadBuffer(size_t requestedSize, size_t& actualSize);
         virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&);
         virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-        virtual void didReceiveData(ResourceHandle*, const char*, int, int);
+        virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int);
         virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedLength);
         virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
         virtual void didFail(ResourceHandle*, const ResourceError&);
@@ -1117,7 +1117,7 @@ void ResourceHandleStreamingClient::didReceiveResponse(ResourceHandle*, const Re
     handleResponseReceived(response);
 }
 
-void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char* data, int length, int)
+void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char* data, unsigned length, int)
 {
     ASSERT_NOT_REACHED();
 }
index 3769641..776f9fd 100644 (file)
@@ -85,7 +85,7 @@ public:
     BlobResourceSynchronousLoader(ResourceError&, ResourceResponse&, Vector<char>&);
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/) OVERRIDE;
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) OVERRIDE;
     virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) OVERRIDE;
     virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
 
@@ -117,7 +117,7 @@ void BlobResourceSynchronousLoader::didReceiveResponse(ResourceHandle* handle, c
     static_cast<BlobResourceHandle*>(handle)->readSync(m_data.data(), static_cast<int>(m_data.size()));
 }
 
-void BlobResourceSynchronousLoader::didReceiveData(ResourceHandle*, const char*, int, int)
+void BlobResourceSynchronousLoader::didReceiveData(ResourceHandle*, const char*, unsigned, int)
 {
 }
 
index b3a5923..aa4b79a 100644 (file)
@@ -67,7 +67,7 @@ namespace WebCore {
 
         virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
         
-        virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/) { }
+        virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) { }
         virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedDataLength);
         
         virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) { }
@@ -122,7 +122,7 @@ namespace WebCore {
 
 #elif PLATFORM(MAC)
         virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *response) { return response; }
-        virtual void willStopBufferingData(ResourceHandle*, const char*, int) { }
+        virtual void willStopBufferingData(ResourceHandle*, const char*, unsigned) { }
 #endif
 
     };
index a60dfb9..994682f 100644 (file)
@@ -67,7 +67,7 @@ void SynchronousLoaderClient::didReceiveResponse(ResourceHandle*, const Resource
     m_response = response;
 }
 
-void SynchronousLoaderClient::didReceiveData(ResourceHandle*, const char* data, int length, int /*encodedDataLength*/)
+void SynchronousLoaderClient::didReceiveData(ResourceHandle*, const char* data, unsigned length, int /*encodedDataLength*/)
 {
     m_data.append(data, length);
 }
index 7d4bf6e..abcd6f5 100644 (file)
@@ -60,7 +60,7 @@ private:
     virtual bool shouldUseCredentialStorage(ResourceHandle*) OVERRIDE;
     virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) OVERRIDE;
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/) OVERRIDE;
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) OVERRIDE;
     virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) OVERRIDE;
     virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
index 772ea80..0610deb 100644 (file)
@@ -37,7 +37,7 @@ BlobStream::~BlobStream()
 {
 }
 
-void BlobStream::didReceiveData(ResourceHandle*, const char* data, int len, int)
+void BlobStream::didReceiveData(ResourceHandle*, const char* data, unsigned len, int)
 {
     notifyDataReceived(BlackBerry::Platform::createNetworkBufferByWrappingData(data, len));
 }
index 2f8ded5..9e864b8 100644 (file)
@@ -38,7 +38,7 @@ public:
     virtual const BlackBerry::Platform::String mimeType() const OVERRIDE;
 
     // From class ResourceHandleClient.
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int) OVERRIDE;
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int) OVERRIDE;
     virtual void didFinishLoading(ResourceHandle*, double) OVERRIDE;
     virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
 
index c16402e..106d533 100644 (file)
@@ -44,7 +44,7 @@ public:
     WebCoreSynchronousLoader();
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int);
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int);
     virtual void didFinishLoading(ResourceHandle*, double);
     virtual void didFail(ResourceHandle*, const ResourceError&);
 
@@ -70,7 +70,7 @@ void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const Resourc
     m_response = response;
 }
 
-void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)
+void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, unsigned length, int)
 {
     m_data.append(data, length);
 }
index 4013cf3..bb927f3 100644 (file)
@@ -48,7 +48,7 @@ public:
     WebCoreSynchronousLoader();
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int encodedDataLength);
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int encodedDataLength);
     virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
     virtual void didFail(ResourceHandle*, const ResourceError&);
 
@@ -71,7 +71,7 @@ void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const Resourc
     m_response = response;
 }
 
-void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)
+void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, unsigned length, int)
 {
     m_data.append(data, length);
 }
index 97a8cb4..b134f55 100644 (file)
@@ -206,7 +206,7 @@ using namespace WebCore;
     // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
     // However, with today's computers and networking speeds, this won't happen in practice.
     // Could be an issue with a giant local file.
-    m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], static_cast<int>([data length]));
+    m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], static_cast<unsigned>([data length]));
 }
 
 - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
index c69a165..1a4beb4 100644 (file)
@@ -303,7 +303,7 @@ using namespace WebCore;
         // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
         // However, with today's computers and networking speeds, this won't happen in practice.
         // Could be an issue with a giant local file.
-        m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], static_cast<int>([data length]));
+        m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], static_cast<unsigned>([data length]));
     });
 }
 
index ae471b7..f7a54ba 100644 (file)
@@ -144,7 +144,7 @@ public:
         m_response = response;
     }
 
-    virtual void didReceiveData(ResourceHandle*, const char* /* data */, int /* length */, int)
+    virtual void didReceiveData(ResourceHandle*, const char* /* data */, unsigned /* length */, int)
     {
         ASSERT_NOT_REACHED();
     }
index 0f66b70..77f0462 100644 (file)
@@ -87,7 +87,7 @@ public:
     HINTERNET internetHandle() const { return m_internetHandle; }
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int encodedDataLength);
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int encodedDataLength);
     virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
     virtual void didFail(ResourceHandle*, const ResourceError&);
 
@@ -116,7 +116,7 @@ void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const Resourc
     m_response = response;
 }
 
-void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)
+void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, unsigned length, int)
 {
     m_data.append(data, length);
 }
index b490a65..7bff0d3 100644 (file)
@@ -1,3 +1,13 @@
+2014-01-06  László Langó  <lango@inf.u-szeged.hu>
+
+        Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
+        https://bugs.webkit.org/show_bug.cgi?id=124579
+
+        Reviewed by Anders Carlsson.
+
+        * webkit/webkitdownload.cpp:
+        (DownloadClient::didReceiveData):
+
 2014-01-02  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         REGRESSION(r160304): [GTK] Disable libtool fast install
index 1f5500c..ae2f21f 100644 (file)
@@ -67,7 +67,7 @@ public:
     DownloadClient(WebKitDownload*);
 
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int);
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int);
     virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int encodedLength);
     virtual void didFinishLoading(ResourceHandle*, double);
     virtual void didFail(ResourceHandle*, const ResourceError&);
@@ -941,7 +941,7 @@ void DownloadClient::didReceiveResponse(ResourceHandle*, const ResourceResponse&
     }
 }
 
-void DownloadClient::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
+void DownloadClient::didReceiveData(ResourceHandle*, const char* data, unsigned length, int encodedDataLength)
 {
     ASSERT_NOT_REACHED();
 }
index 0a4d26d..d89af41 100644 (file)
@@ -1,3 +1,13 @@
+2014-01-06  László Langó  <lango@inf.u-szeged.hu>
+
+        Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
+        https://bugs.webkit.org/show_bug.cgi?id=124579
+
+        Reviewed by Anders Carlsson.
+
+        * WebKitDLL.cpp:
+        (loadResourceIntoBuffer):
+
 2013-12-30  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Cleanup static_cast<HTMLFormElement*> by using toHTMLFormElement()
index ef85608..5d440ee 100644 (file)
@@ -202,7 +202,7 @@ PassRefPtr<WebCore::SharedBuffer> loadResourceIntoBuffer(const char* name)
     void* resource = LockResource(res);
     if (!resource)
         return 0;
-    int size = SizeofResource(gInstance, resInfo);
+    unsigned size = SizeofResource(gInstance, resInfo);
 
     return WebCore::SharedBuffer::create(reinterpret_cast<const char*>(resource), size);
 }
index 4ec06bf..642eda3 100644 (file)
@@ -1,3 +1,17 @@
+2014-01-06  László Langó  <lango@inf.u-szeged.hu>
+
+        Use unsigned consistently, and check for invalid casts when calling into SharedBuffer from other code.
+        https://bugs.webkit.org/show_bug.cgi?id=124579
+
+        Reviewed by Anders Carlsson.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::didReceiveData):
+        (WebKit::NetworkResourceLoader::willStopBufferingData):
+        * NetworkProcess/NetworkResourceLoader.h:
+        * Shared/Downloads/soup/DownloadSoup.cpp:
+        (WebKit::DownloadClient::didReceiveData):
+
 2014-01-04  Simon Fraser  <simon.fraser@apple.com>
 
         Add encoding of ViewportConstraint and ScrollingParameter types
index 0738929..ba89c8e 100644 (file)
@@ -191,7 +191,7 @@ void NetworkResourceLoader::didReceiveResponseAsync(ResourceHandle* handle, cons
     }
 }
 
-void NetworkResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
+void NetworkResourceLoader::didReceiveData(ResourceHandle*, const char* data, unsigned length, int encodedDataLength)
 {
     // The NetworkProcess should never get a didReceiveData callback.
     // We should always be using didReceiveBuffer.
@@ -398,7 +398,7 @@ void NetworkResourceLoader::didReceiveDataArray(ResourceHandle*, CFArrayRef)
 #endif
 
 #if PLATFORM(MAC)
-void NetworkResourceLoader::willStopBufferingData(ResourceHandle*, const char*, int)
+void NetworkResourceLoader::willStopBufferingData(ResourceHandle*, const char*, unsigned)
 {
     notImplemented();
 }
index 9d23032..f2f63d5 100644 (file)
@@ -82,7 +82,7 @@ public:
     virtual void willSendRequestAsync(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) OVERRIDE;
     virtual void didSendData(WebCore::ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
     virtual void didReceiveResponseAsync(WebCore::ResourceHandle*, const WebCore::ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(WebCore::ResourceHandle*, const char*, int, int encodedDataLength) OVERRIDE;
+    virtual void didReceiveData(WebCore::ResourceHandle*, const char*, unsigned, int encodedDataLength) OVERRIDE;
     virtual void didReceiveBuffer(WebCore::ResourceHandle*, PassRefPtr<WebCore::SharedBuffer>, int encodedDataLength) OVERRIDE;
     virtual void didFinishLoading(WebCore::ResourceHandle*, double finishTime) OVERRIDE;
     virtual void didFail(WebCore::ResourceHandle*, const WebCore::ResourceError&) OVERRIDE;
@@ -108,7 +108,7 @@ public:
 #if !PLATFORM(IOS)
     virtual void willCacheResponseAsync(WebCore::ResourceHandle*, NSCachedURLResponse *) OVERRIDE;
 #endif
-    virtual void willStopBufferingData(WebCore::ResourceHandle*, const char*, int) OVERRIDE;
+    virtual void willStopBufferingData(WebCore::ResourceHandle*, const char*, unsigned) OVERRIDE;
 #endif // PLATFORM(MAC)
 
     // Message handlers.
index a5a08b6..5da8d9a 100644 (file)
@@ -110,7 +110,7 @@ public:
         m_download->didCreateDestination(destinationURI);
     }
 
-    void didReceiveData(ResourceHandle*, const char* data, int length, int /*encodedDataLength*/)
+    void didReceiveData(ResourceHandle*, const char* data, unsigned length, int /*encodedDataLength*/)
     {
         if (m_handleResponseLaterID) {
             g_source_remove(m_handleResponseLaterID);