<http://webkit.org/b/67983> CRASH under WebCore::ArchiveResourceCollection::addAllRes...
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2011 19:24:52 +0000 (19:24 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2011 19:24:52 +0000 (19:24 +0000)
Reviewed by Darin Adler.

Source/WebCore:

Null mimetypes are okay for subresources, but as previously discovered
in bug 41082 they were required for main resources. Here we ensure
that they are required for main resources, but we allow null mimetypes
for subresources.

To fix a crash for bad input we never add a null ArchiveResource to the
Archive's subresource collection. It is useless and causes crashes whenever
someone iterates the Archive's subresource collection.

Test: webarchive/loading/test-loading-archive-subresource-null-mimetype.html

* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createResource):
Allow a null mimetype, just type check from the dictionary.

(WebCore::LegacyWebArchive::extract):
Require a mimetype for the main resource. Do not add null
subresources to the subresource list.

LayoutTests:

Test a WebArchive that has been constructed to have a null
mimetype for a subresource.

* webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt: Added.
* webarchive/loading/test-loading-archive-subresource-null-mimetype.html: Added.
* webarchive/loading/resources/subresource-null-mimetype.webarchive: Added.

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

LayoutTests/ChangeLog
LayoutTests/webarchive/loading/resources/subresource-null-mimetype.webarchive [new file with mode: 0644]
LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt [new file with mode: 0644]
LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp

index e52f919..e869d43 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-13  Joseph Pecoraro  <joepeck@webkit.org>
+
+        CRASH under WebCore::ArchiveResourceCollection::addAllResources loading WebArchive
+        https://bugs.webkit.org/show_bug.cgi?id=67983
+
+        Reviewed by Darin Adler.
+
+        Test a WebArchive that has been constructed to have a null
+        mimetype for a subresource.
+
+        * webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt: Added.
+        * webarchive/loading/test-loading-archive-subresource-null-mimetype.html: Added.
+        * webarchive/loading/resources/subresource-null-mimetype.webarchive: Added.
+
 2011-09-13  Ryosuke Niwa  <rniwa@webkit.org>
 
         Update chromium test expectation since fast/borders/border-image-omit-right-slice.html no longer hits an assertion.
diff --git a/LayoutTests/webarchive/loading/resources/subresource-null-mimetype.webarchive b/LayoutTests/webarchive/loading/resources/subresource-null-mimetype.webarchive
new file mode 100644 (file)
index 0000000..0900bd3
--- /dev/null
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>WebMainResource</key>
+       <dict>
+               <key>WebResourceData</key>
+               <data>
+               PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5PjxpbWcgc3JjPSJ0ZXN0LnBuZyI+
+               PC9ib2R5PjwvaHRtbD4=
+               </data>
+               <key>WebResourceFrameName</key>
+               <string></string>
+               <key>WebResourceMIMEType</key>
+               <string>text/html</string>
+               <key>WebResourceTextEncodingName</key>
+               <string>UTF-8</string>
+               <key>WebResourceURL</key>
+               <string>file:///test-archive.html</string>
+       </dict>
+       <key>WebSubresources</key>
+       <array>
+               <dict>
+                       <key>WebResourceData</key>
+                       <data>
+                       iVBORw0KGgoAAAANSUhEUgAAACYAAAAkCAIAAABql9/yAAAWmGlD
+                       Q1BJQ0MgUHJvZmlsZQAAeAGtWHdUFM+y7tnMskvOOeecc85BckZk
+                       yTlnJIrwA8kCIogIKhIURCWoqCRFREmKIElQERBQDCgiyBv06r3v
+                       nHf/e3POzHxdU13T09XTVfUBwKRECgsLQlABEBwSFWFtqMPl6OTM
+                       hZ0BOMAJ6IAkECF5RoZpW1qagf96fH0OoIOHT8UPbP1Xtf/7AbWX
+                       d6QnAJAl/NjDK9IzGMY34FPNMywiCgDEJiznjY0KgzGSDsZ0EfAA
+                       YSx0gH1/Y7UD7PEbH9ihi7C11oV1vADAEUikCF8AyMNgOVeMpy9s
+                       h7wQAAxNiJd/CADUF2Cs4elHgnUZ38A6YsHBoTBmooKxkMd/2PH9
+                       D0wiefy1SSL5/sW/vwXuCb9Yzz8yLIgU/6vx/3kJDoqG5+vXwQBf
+                       CWFROtbwnQ+eMyb/KGPbP9gv2sjuD07ws3X4g0M8Dln8wZ6RuvBc
+                       /u4bGGr6146Xt57+H3lkjM1fnOCne+iPPIBkcjDXv95LioDRv3BY
+                       lOXfMYQEHTpYN790fCIM/tr3jtS3+SOPgp31B/v4Gxj/wWFBv9bc
+                       r74R0dZ/v8U7xO5vXy+SnukffWAG9IEe4AK6wB+EAG8QDEhwSw9u
+                       RYIwEAS34qO842D/A6AbGhYf4e/rF8WlDa9YbzEu4xBPCTEuGSlp
+                       aXCw/g90APhs/WtdQwwj/5ZFdgGgejCml/+WuTUC0DEJL7u2f8v4
+                       QgEgogHoOu0ZHRHz2x7q4IYGeEAJ/1nMgAPwAiEgDmSAAlAFWvDo
+                       TYAFsAVOwA14Aj94/BEgFhwFaSATnACFoBRUgGpwHtSDK+Aa6ABd
+                       oAc8AENgFEyAGbAAlsAa2ARfwQ8IgrAQEaKFmCFOiB8ShWQgJUgD
+                       0ofMIGvICXKHfKEQKBo6Ch2DTkDFUAVUAzVArdBNqAcahMagF9Ai
+                       tAp9gnYQSAQBQYdgRwggJBFKCG2EKcIWcRjhiwhHJCAyEPmIckQt
+                       4jKiHdGDGEJMIBYQa4gtJECSIxmQ3EhxpBJSF2mBdEb6ICOQycgc
+                       ZBmyFtmMvIUcQD5FLiDXkd9RGBQtigsljlJFGaHsUJ6ocFQyKhdV
+                       gapHtaP6UU9Ri6hN1E80Ec2GFkWroI3RjmhfdCw6E12GrkO3oe+j
+                       J9BL6K8YDIYBI4hRxBhhnDABmERMLqYK04LpxoxhXmO2sFgsM1YU
+                       q461wJKwUdhM7GnsZew97Dh2CbuNI8dx4mRwBjhnXAguHVeGa8Td
+                       xY3jlnE/yKjI+MlUyCzIvMjiyQrILpDdIhshWyL7gafGC+LV8bb4
+                       AHwavhzfjL+Pn8V/Jicn5yFXJrci9ydPJS8nv0r+kHyR/DuBhiBC
+                       0CW4EqIJ+YRLhG7CC8JnIpEoQNQiOhOjiPnEBmIfcZ64TUFLIUFh
+                       TOFFkUJRSdFOMU7xnpKMkp9Sm9KNMoGyjPI65QjlOhUZlQCVLhWJ
+                       Kpmqkuom1STVFjUttTS1BXUwdS51I/Ug9QoNlkaARp/GiyaD5jxN
+                       H81rWiQtL60urSftMdoLtPdpl+gwdIJ0xnQBdCfortAN023S09DL
+                       0dvTx9FX0t+hX2BAMggwGDMEMRQwXGN4zrDDyM6ozejNmM3YzDjO
+                       +I2JlUmLyZsph6mFaYJph5mLWZ85kLmIuYN5jgXFIsJixRLLcpbl
+                       Pss6Kx2rKqsnaw7rNdZpNgSbCJs1WyLbebbHbFvsHOyG7GHsp9n7
+                       2Nc5GDi0OAI4Sjjucqxy0nJqcPpzlnDe43zHRc+lzRXEVc7Vz7XJ
+                       zcZtxB3NXcM9zP2DR5DHjiedp4VnjhfPq8Trw1vC28u7ycfJZ853
+                       lK+Jb5qfjF+J34//FP8A/zcBQQEHgSyBDoEVQSZBY8EEwSbBWSGi
+                       kKZQuFCt0DNhjLCScKBwlfCoCEJEXsRPpFJkRBQhqiDqL1olOiaG
+                       FlMWCxGrFZsUJ4hri8eIN4kvSjBImEmkS3RIvJfkk3SWLJIckPwp
+                       JS8VJHVBakaaRtpEOl36lvQnGREZT5lKmWeyRFkD2RTZTtmPcqJy
+                       3nJn5abkaeXN5bPke+X3FBQVIhSaFVYV+RTdFc8oTirRKVkq5So9
+                       VEYr6yinKHcpf1dRUIlSuabyQVVcNVC1UXVFTVDNW+2C2mt1HnWS
+                       eo36ggaXhrvGOY0FTW5Nkmat5istXi0vrTqtZW1h7QDty9rvdaR0
+                       InTadL7pqugm6XbrIfUM9XL0hvVp9O30K/TnDXgMfA2aDDYN5Q0T
+                       DbuN0EamRkVGk8bsxp7GDcabJoomSSb9pgRTG9MK01dmImYRZrfM
+                       EeYm5ifNZw/xHwo51GEBLIwtTlrMWQpahlvetsJYWVpVWr21lrY+
+                       aj1gQ2tzxKbR5qutjm2B7YydkF20Xa89pb2rfYP9Nwc9h2KHBUdJ
+                       xyTHIScWJ3+nTmess71znfOWi75LqcuSq7xrpuvzw4KH4w4PurG4
+                       BbndOUJ5hHTkujva3cG90X2XZEGqJW15GHuc8dj01PU85bnmpeVV
+                       4rXqre5d7L3so+5T7LPiq+570nfVT9OvzG/dX9e/wv9jgFFAdcC3
+                       QIvAS4H7QQ5BLcG4YPfgmyE0IYEh/aEcoXGhY2GiYZlhC+Eq4aXh
+                       mxGmEXWRUOThyM4oOjjReBwtFH08ejFGI6YyZjvWPvZ6HHVcSNzj
+                       eJH47PjlBIOEi4moRM/E3qPcR9OOLiZpJ9UkQ8keyb0pvCkZKUup
+                       hqn1afi0wLQn6VLpxelfjjkcu5XBnpGa8fq44fGmTIrMiMzJLNWs
+                       6n9Q//j/M5wtm306+2eOV86jE1Inyk7s5nrmPsqTzivP28/3yR8u
+                       UCg4W4gpDCl8XqRZVF9MXZxQ/Pqk+cn2Eq6SnJIvpUdKB8vkyqpP
+                       4U9Fn1ooNyvvPM13uvD0boVfxUSlTmXLGbYz2We+VXlVjZ/VOttc
+                       zV59onrnnP+5qRrDmvZagdqy85jzMeffXrC/MHBR6WJDHUvdibq9
+                       SyGXFuqt6/sbFBsaGtkaC5oQTdFNq5ddL49e0bvS2SzeXNPC0HLi
+                       KrgaffVdq3vr82um13qvK11vvsF/40wbbVtOO9Qe377Z4dex0OnU
+                       OXbT5GbvLdVbbbclbl/q4u6qvEN/p+Au/m7G3f17Cfe2usO613t8
+                       e173Humd6XPse9Zv1T983/T+wwcGD/oGtAfuPVR/2DWoMnjzkdKj
+                       jiGFofbH8o/bnsg/aRtWGG4fURzpHFUevTWmNnZ3XHO856ne0wfP
+                       jJ8NTRyaGHtu93xq0nVyYcprauVF0IuP0zHTP2ZSZ9GzOXNUc2Xz
+                       bPO1L4VftiwoLNxZ1Ft8/Mrm1cxrz9drbyLf7C5lvCW+LVvmXG5Y
+                       kVnpWjVYHX3n8m5pLWztx3rmBvXGmfdC72980PrweNNxc+ljxMf9
+                       T7mfmT9f+iL3pXfLcmv+a/DXH99ytpm3678rfR/YcdhZ/hG7i90t
+                       3xPeu/XT9OfsfvD+fhgpgvQrF0DCV4SPDwCfLsF5ghMAtKMA4Cl+
+                       56e/NOD0FU6qETC2h3ihqwgnJD3yDaoVnYcJxlrh1Mj48UzkNAQc
+                       EUWBpaSmoqfmoBGj1aA7RO/LkMCYx1TN3Mxyk/UB2wz7R04KLklu
+                       a55w3hy+Kv4WgduC94VGhadE5kUXxZbEVyU+SH6W+iGDkiXI0cmz
+                       KvAoCigJK4upiKuKq4mqC2sIavJrcWtz6rDpMuvR6VMaYA32Db8Z
+                       bRi/NpkyfWzWY952qMGi2rLcqsT6pE2xbZFdoX2+Q45jltMx52SX
+                       ONeIw4FuPkc83b1JAR7hnke9srwLfcp9a/wa/FsC2gNvB3UHPwgZ
+                       Dp0KWwnfjaSLkog2jCHFJsaVxDcl9CVOH91MRqcwpQqlyadrHTPM
+                       MD9ulWmX5fCPc7ZrzuETbrlueW757gVehUFFicX5J+tK7pY+L9so
+                       R51mqZCq1D/jXBVy9lh1xblrNU9q1y6QXRSsM7jkVZ/WUN3Y1TR1
+                       +UszZYvgVZVW42s2151uuLV5tPt0BHSG3Ay/FXU7pivuTsLdpHtp
+                       3dk9p3ov9XX1j95fevD9IXGQ+5HskMFjxyf+wwkjWaNFY2Xjp56W
+                       PCucyHmeMZk0FfMiZNpnxm3Wfs58Xv+l2oL8ouQr0deCb/iWuN6y
+                       LzOvMKzSvKNcI1/HbiA3fr7f/rCx+eLjnU8VnyO+GG6xb33+Ovit
+                       Zjvuu8UO/87uj/Hd+r3kn7b7Ivv7sP9FQT9UCvufBvkQVYKOxFhj
+                       BXFkuC9kM/gh8n7CbWI7RSdlJ9Vt6n6aIdoZunf0XxlRTFTMzCwc
+                       rDxsIuyKHIc4A7hSuU/xNPC28/XyDwoMC44IjQmPwbHvidiQ+IBE
+                       n2SPVLd0t0yPbI9cj/w9hS7FW0rtyq0qTarn1SrUizWyNVO0orQD
+                       ddx1bfUM9JUNRA3ZjYhGe8brJtOmD83azGsPFVokW4ZbeVu72Fjb
+                       mtjp2Cs5SDjyOTE7U7ggXLZcVw7Puo0dGXTvJ/V5PPAc9HriPe7z
+                       3PeF36z/fMDLwIWgxeBXIUuh78I+R0CRNFH80YoxxrGuccHxyQn5
+                       iWePXkm6nfww5WnqTNpi+tKx5YyV46uZ77Le/bOavZLz9sRS7qu8
+                       xfyFgteFq0VbJ1ElDKVCZaqnzMrdTodWpFYWnjlX1Xq2t3ri3Lta
+                       5Hn2C8oX7esiLuXVNzT0Nc41fbtC2SzQonrVvNX5mvf1oBsRbXHt
+                       SR3pnVk3T9wquH2yq+xOxd3qe3XdrT3dveN9K/0/H9ANiDzUGrR/
+                       FDiU+rjkSf1w18iT0ZmxpfH1p5vPvkx8e74zuTe1Pw3NIGdRc+h5
+                       zEvsAn6R6hXTa943kkuqbw2WrVZcV33fha8lrh/fKHhf/qF68/zH
+                       2k9Vn0u/5G6lf439FrRN+m63Y/JDY1dmj/8n8z7hr//DEBKIDWQZ
+                       ygbNhd7APMCW40LILPBK5JwEFOEjcYliinKQ6j71XZou2jt0XfR3
+                       GPoYB5nGmF+x/GTjZDfmiOGs5RrkXuVF8rHwiwqoC5oI2QkfEfET
+                       DROLEU+USJPMksqVLpY5LXtO7pL8ZYWrijeUOpQ7VTpU29VuqF/V
+                       uKJZp1WjXaFTqJull6wfYeBr6GxkZqxuImnKYUY02zVfOzRtMWR5
+                       x6rVut6m2vaUXZ79MYd4xxAnD2d7FyNXlcNibpxHaN3xJLQH0hPh
+                       hfRG+2B8sX5Yf0wAOhAVhAgGwT9D9kL3wzERlJGsUcLRSjGGsbZx
+                       pPiQhPjE40fzk8qTa1LqUhvS6tMvHjuXUXG8JDMvK+OfpOyonKAT
+                       nrlOeZb5RgU6hZpF2sVGJ61KDpf6lUWeSinPPn2y4kzlxTNXqtrP
+                       3qsePPe8Zrn2+wXiRa46uUuG9c4NwY0pTYWXa660Nne3DF192jp1
+                       bfr69I2ptsn2Zx3jnSM3n9x6dHugq/9O792ee73dAz2jvXN9G/17
+                       DygGOB5KDKo/Mhtyeez/JHb42Ej+aNlYxfiZp5XPTk+UPS+ZLJzK
+                       e5E9fXwmfTZ5LnE+7mXcQuJi2qsTr8vf1C3deNu3PLoyv7r2bnsd
+                       vUHznvOD+KbmR7tP4Z+Lvlzfmvj6bZv5u+qO64+k3bN7d3++PPD/
+                       b57iICZgFACoYwTAbgQA05sAnG0FgH8Vjh/cAFgSAbBVBggtOGZw
+                       GwIEI/5v/IDgmpMc0ABWwA+kgQYwB4fh+jgNricbQTeYAh8hckgA
+                       0oXrwhToHNQLvYWrPjm4zstEtCJmkTikPNILWYocRO6jFFERqBbU
+                       BloCHY7uQP/EGGKKMPNwdZWAHcJx4CJxj8j4yFLJ5vGa+FpyHHkY
+                       +TTBgNBG5CeWUxApjlPsUyZR7lGlUKOp82iYaC7SytMO0LnQfaDP
+                       YGBmuMpozPiGKZ2Zl/kBSxArPWsPWyg7F/s4x3FORc5Vrkpucx6I
+                       p5M3gk+Cb52/WSBcUEkIEnosXC7iLSoluiPWJ35Cwk6SW/KD1D3p
+                       IhkfWXU5BrlP8mMK1xXLldKVw1W8VF3VHNUdNJw0j2j5aIfrpOgW
+                       6J3X7zQYMVwy2jbBmtKZcZqLHVKxMLM8YhVjXWDTaPvQbtWB4Cjl
+                       ZOec4HLWtffw8hEKdwWSu0ee5x2v9z48vk5+Rf5PAolBNsHnQr6G
+                       2YZ3RnJG5UR/i/WNe5FgkfgwSTe5N1U37T4ct+5namS1ZYvk1OQy
+                       55UW0BaWFDOdrC4VLmsr1zs9VRlZxXC2/1xircr5nxcfXipt8G5S
+                       vkLdvHZ18Frjjfz26M7Dtwy6xO/S39vvWe+bvT8ycH+wa6jjSdtI
+                       29itp70To5Nr02zwNjqyaPC6/63uSt+awcaTTadPq1vJ20w77XuO
+                       v/YPxC//0wI2IABkgTawhJmQSJhTqASt4CFYhPkCBkgWsoRCoULo
+                       GvQc2kXwIQ4h4hEXEWOIPaQY0hWZj+xD7qBkUaGoK6j3aCl0NLoL
+                       g8ZYYs5iNrAa2ELsG5wKrhi3TmZMVo8nwwfjn5KrkdcTGAiZhO/E
+                       UOJbCneKOcrDlC+pvKjWqGNokDQltILwPmVP95E+n0GUYZDRj4mM
+                       qYnZknmb5TyrJRtgu87uz8HDMcdZweXITc89zpPPa8qH53vEnydg
+                       I8gq+FbohnCGiIOomBhSbFq8VSJT0llKQholPSvTLlssFy5vraCg
+                       yKaEVvqovKAyrjqo1q/erzGgOaL1Qvutzlc9nD6HgaKhtVG4cZHJ
+                       DdMJs61DNBZilgZW7tZJNpW2d+wWHbCw312dc1xuur5zYzti7p5E
+                       uuIx50Xhre0T69vitxogEOgTVB+8EaoQlh7+LFIsKjf6Y+zhuMcJ
+                       GonXk0ST61J50y4cE8y4kimfdTfbIOdRrmneYIFBYV+x7sn7pcZl
+                       o+XOp5cro6uwZyvPydaMno+Cd6Rn9QWNhy5TXZloqWr1u67Yhmuf
+                       62y7VdAVdNe4m69nt2/8fv1A6qDLkPITluGfo0vjI89uP2+aqpou
+                       mS2aP7XQ9OrRm0/LnKuWa8c37n74/kn5y9Gvvd+JP5z3mv7lfwwg
+                       AHqYzxUFSsAI5pcCQQr8918G/WAe7MDel4dsYT6oHOqCFhE4hBTC
+                       EZGKaECMI3aRgkhb5DFkG3IVxYlyRBWjRtAUaAt0MXoSw4Hxw1zH
+                       AphXOYf9BHMoZ+CMxIKsCY/HB+JHyBXIzxLwhFjCCtGFOAqzG/0w
+                       n9FLpU81RG1LvUATQgtoS+hE6frp3el3GSoYlRinmBKYOZkHWMJZ
+                       OViH2dLYFdk3OS5z+nMJci1xn+dx5+XkfclXw+8jICGwDeevpcK+
+                       ImqidKIbYgPi5yTiJC2lhKQh2P83ZU/LHZUnKRgryipxK1OroFR2
+                       Vb+r7WogNSm1OLVldIx0PeAIVmVwz/CNMcFEwdTDLBfOYKct9qy4
+                       rHVt/OH89bb9qiOzk5lzustt169uskfC3ZtJq558Xu7eVT5zfhz+
+                       ngGNgZ+DtUIKQhfDFSIKIt9H28b0xMnFX0kUPdqULJnSnqaV/jjD
+                       5fhGVlo2Y05zrl7eZIF34WZxfAmqtPAUZ3lrhUHlfFVcNcO59lrn
+                       C4iLLZe8Grgb316+2px61fqa0A1E23zHnZvVtzPuBN6z6VHv47uP
+                       ffD2YfejisdRw1ajUuO0T7cnFiaHXnTONMxVvsxfTHkdsGSxLLGK
+                       f7e8/uD9pc2cT2FfHL/qbkvvcO/S/sQd+D/SR1YGDh4wZUnQgenH
+                       +f39zwIAYIsB2Cva3/9Ru7+/dx4uNmYB6A76zX0fKGNg/rtYAbEE
+                       aG90zB8I/tfxP5BnSFTV3kHUAAAACXBIWXMAAAsTAAALEwEAmpwY
+                       AAAGKklEQVRYCV2XW3bFqA5EDXYGcMfUg+n5f8ePu3cVxzmrSWKD
+                       niUhZDL+/ed/c84xxuMYW8Z9n/uAPFnd913iNvfnuT4C93EcKLCs
+                       4is2nq0GlRwnYmU992DC8vjoqLht+mDobOgeoUWfA9tj7OHfQGRk
+                       jiBwXUYyNOaBsj3jvJ7rEvTcQDyu6wEpmvpj1ASTeBz3NkNTQBt/
+                       Qx9FU08X/IqOsVAvYVb8ikho/h2H6ZuNhrWa2CK2JPvPCXTGvjdK
+                       6eOZz31uAczGNCvQK4kprCiWZPQJa5t3E4ueWLTE6x5zR8bh8hM9
+                       y9dKgtYiXOlJXeUhMbE6DPiemn3YJ4TZJBTXXhpXROW+viF90qWF
+                       D1536jbiqkC/LstqCbgvDrjQ8Q8rhcibkSh5v+aYIj2eO7AUqVdt
+                       bM95r4oVcAYbgwLqa50Xiw1v1wUsHC7WmBd5ZTNhvC7hwe8SSxQW
+                       lCTzfq4FHopBJhPKM9223yS2iuSUH+Yo4mMHKmCDCRvQTSxDQ8lA
+                       55eGCBWyw/mc560MK7HnBLOkRHiyVYgBkuoC49y3m+jGDTixat48
+                       F8jx8/PDokN/pgx5N6AjbhagVwwWdAV4zkl6YeFyGkZbgROIFAcG
+                       NVxYJPY8z/AuTOy77pW983QWtUz6KAISq/3koRRdqmtVW1nTiQVA
+                       QvSgR7LDUThSeG4UmuQ8SSBZVFCQPcS7ItZotgR15hfY3UeGcOOS
+                       ICUxN3xGodNUSGrm4Dygw0ZOH8t4xWOlthCi2IggOYiKy7ZkoNKT
+                       6wmEiLAxPdjUjsIkIw02ULbj9/cXaQ9srJdqDFrn183KhBdQrQCE
+                       lcdyIKLXXo11B4pzkkMPWyrOAk5vaKobpeEpEa8A1O4Y53dMk1Be
+                       HzEdYWYIw+LZOVjtihQ98qTFQ47Mqn44HhJEcVCX+EOHwbIHyA38
+                       DOhLHnaqlCWT/7iEyNAI1gIIAx5lDbuXVlq3WeV0KSTgFVjqS1Fq
+                       G/oPnR34+B4U5NguGtj4DSaFcLOTRd569bRxEI4AvalxzXKiDgs1
+                       In0ihPT3U+1QYtlHJSEySSdSxcHxz7a5i5SSe+muXe59tVaPpSg+
+                       zXOZJsHEjJAHgFFztNg4MxfU0B8rvvXoR3zkPMSZ7kPW4zw9QtNb
+                       QiLMsS1qYD8n+YTlaTKHgO9E10XlmkHzKa3+0l2XRA/pBw1prmTu
+                       L9os/CQqlV07oCZY5gffAUuBSjY4fGGqMpk3YCJaRACI5auLIRzF
+                       6+D8sNtKfAYuOJX2K0+FBQsnLrgr4BaK3dtPjDYEAjEyNlMSwzxA
+                       m9N4NiqKVnMchLXh1eEZH89qHwbZfFCnfATNdYI0qfilOPxUfEZh
+                       al2/7brMHo+4ec0LIT6Z98MthguIMWErXpcZ40pIjQpWufo0F0J5
+                       KdWJSO5zKLJlaTJCEOJu9/HKRZURL+5FR/xUMAk9uAacm6XEigtf
+                       Y7rvX9LHKUO6AYJZGxk1TQEyQfE6yaLR8YSPCxLLt1corK17tsh9
+                       ZalvcPFAjnntmmbjY6BhzlX8+4Co9Q7yV7nILHJv3Gn+amKG24pu
+                       yo8oD/3zBLW3GbD+HUvPLh/ayuOgku/kXVIcgU6U5IMMfw0/Ulku
+                       t3GGP+LDOk0bAFjMXdfOxrTazL7MuE0AhOKVzPOyuo172dvRlwLp
+                       ki2FPyogw2nnppp5USOy2ghSdclE9gprY1dZlwvdBluJF6DNLHEg
+                       CREuo1xPTM5MPx45oISo71cGSex2uA0ZCDQD1KAfqNQAEZnP5gYF
+                       vCDMi9qsuVA09zFqfBHRajGl9DKFwe3uskWDMgZXAHQfZm6GynqP
+                       8temFC9PKhb1j0vElgkKLmkzmSvjHwQJR0CygpVwD6qQfeF4BJF2
+                       zdI+yQB1SSvk/lJpooWVxBK3IZI3WeobPdxA1wfDYFe7No81wl54
+                       92FRHG6UxaURPr72Iv+8OyXDFGuyrYs323BsEzz2fYGLu0QWtzxi
+                       f+23/9UWXZ7AkXHgd+58sNhIb+bsS758BVSIEHNs9EivAR2/1ANc
+                       rgbtPvIAzX+F/BuiEXH0fiMYhhJBmOaFV5sRYovK+d8pcEOJYFKX
+                       jJmcZpL+pSFN8farwn3PysChZBj/B2MaJrxJctGbAAAAAElFTkSu
+                       QmCC
+                       </data>
+                       <key>WebResourceResponse</key>
+                       <data>
+                       YnBsaXN0MDDUAQIDBAUGNjdYJHZlcnNpb25YJG9iamVjdHNZJGFy
+                       Y2hpdmVyVCR0b3ASAAGGoKsHCB8lJi0uLzAxMlUkbnVsbNsJCgsM
+                       DQ4PEBESExQVFhcYGRobHB0eUiQ2UiQyUiQ3UiQzUiQ4ViRjbGFz
+                       c1IkNFIkOVIkMFIkNVIkMYAHEAeAAIACgAiACoAFgAkQCIAGEADT
+                       DiAhIiMWW05TLnJlbGF0aXZlV05TLmJhc2WABIADgABfECdmaWxl
+                       Oi8vL1VzZXJzL3BlY29yYXJvL0Rlc2t0b3AvdGVzdC5wbmfSJygp
+                       KlokY2xhc3NuYW1lWCRjbGFzc2VzVU5TVVJMoissVU5TVVJMWE5T
+                       T2JqZWN0I0G0HwxuhRs/EAJZaW1hZ2UvcG5nER0cI3/v////////
+                       0icoMzRdTlNVUkxSZXNwb25zZaI1LF1OU1VSTFJlc3BvbnNlXxAP
+                       TlNLZXllZEFyY2hpdmVy0Tg5XxATV2ViUmVzb3VyY2VSZXNwb25z
+                       ZYABAAgAEQAaACMALQAyADcAQwBJAGAAYwBmAGkAbABvAHYAeQB8
+                       AH8AggCFAIcAiQCLAI0AjwCRAJMAlQCXAJkAmwCiAK4AtgC4ALoA
+                       vADmAOsA9gD/AQUBCAEOARcBIAEiASwBLwE4AT0BSwFOAVwBbgFx
+                       AYcAAAAAAAACAQAAAAAAAAA6AAAAAAAAAAAAAAAAAAABiQ==
+                       </data>
+                       <key>WebResourceURL</key>
+                       <string>file:///test.png</string>
+               </dict>
+       </array>
+</dict>
+</plist>
diff --git a/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt b/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt
new file mode 100644 (file)
index 0000000..64df4e3
--- /dev/null
@@ -0,0 +1,14 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didStartProvisionalLoadForFrame
+resources/subresource-null-mimetype.webarchive - willSendRequest <NSURLRequest URL resources/subresource-null-mimetype.webarchive, main document URL test-loading-archive-subresource-null-mimetype.html, http method GET> redirectResponse (null)
+main frame - didFinishDocumentLoadForFrame
+<unknown> - didFinishLoading
+resources/subresource-null-mimetype.webarchive - didReceiveResponse <NSURLResponse resources/subresource-null-mimetype.webarchive, http status code 0>
+frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+ This tests that doing a normal load of a webarchive with a null mimetype for a subresource does not crash.
diff --git a/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html b/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype.html
new file mode 100644 (file)
index 0000000..d4af4cb
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpResourceLoadCallbacks();
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    function frameLoaded() {
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+</script>
+<body>
+    <iframe onload="frameLoaded();" src="resources/subresource-null-mimetype.webarchive"></iframe>
+    This tests that doing a normal load of a webarchive with a null mimetype for a subresource does not crash.
+</body>
+</html>
index 7f7fbe9..bb8f14d 100644 (file)
@@ -1,3 +1,29 @@
+2011-09-13  Joseph Pecoraro  <joepeck@webkit.org>
+
+        CRASH under WebCore::ArchiveResourceCollection::addAllResources loading WebArchive
+        https://bugs.webkit.org/show_bug.cgi?id=67983
+
+        Reviewed by Darin Adler.
+
+        Null mimetypes are okay for subresources, but as previously discovered
+        in bug 41082 they were required for main resources. Here we ensure
+        that they are required for main resources, but we allow null mimetypes
+        for subresources.
+
+        To fix a crash for bad input we never add a null ArchiveResource to the
+        Archive's subresource collection. It is useless and causes crashes whenever
+        someone iterates the Archive's subresource collection.
+
+        Test: webarchive/loading/test-loading-archive-subresource-null-mimetype.html
+
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::createResource):
+        Allow a null mimetype, just type check from the dictionary.
+
+        (WebCore::LegacyWebArchive::extract):
+        Require a mimetype for the main resource. Do not add null
+        subresources to the subresource list.
+
 2011-09-13  Mihai Parparita  <mihaip@chromium.org>
 
         [Chromium] Remove javascript_engine from WebCore.gyp
index 6145dae..fd747ef 100644 (file)
@@ -199,7 +199,7 @@ PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dic
     }
     
     CFStringRef mimeType = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceMIMETypeKey));
-    if (!mimeType || CFGetTypeID(mimeType) != CFStringGetTypeID()) {
+    if (mimeType && CFGetTypeID(mimeType) != CFStringGetTypeID()) {
         LOG(Archives, "LegacyWebArchive - MIME type is not of type CFString, cannot create invalid resource");
         return 0;
     }
@@ -327,6 +327,11 @@ bool LegacyWebArchive::extract(CFDictionaryRef dictionary)
         return false;
     }
     
+    if (mainResource()->mimeType().isNull()) {
+        LOG(Archives, "LegacyWebArchive - Main resource MIME type is required, but was null.");
+        return false;
+    }
+    
     CFArrayRef subresourceArray = static_cast<CFArrayRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveSubresourcesKey));
     if (subresourceArray && CFGetTypeID(subresourceArray) != CFArrayGetTypeID()) {
         LOG(Archives, "LegacyWebArchive - Subresources is not the expected Array, aborting invalid WebArchive");
@@ -341,7 +346,9 @@ bool LegacyWebArchive::extract(CFDictionaryRef dictionary)
                 LOG(Archives, "LegacyWebArchive - Subresource is not expected CFDictionary, aborting invalid WebArchive");
                 return false;
             }
-            addSubresource(createResource(subresourceDict));
+            
+            if (RefPtr<ArchiveResource> subresource = createResource(subresourceDict))
+                addSubresource(subresource.release());
         }
     }