Merge lp:~gue5t/midori/adblock-crashes into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 7087
Merged at revision: 7098
Proposed branch: lp:~gue5t/midori/adblock-crashes
Merge into: lp:midori
Diff against target: 63 lines (+20/-17)
2 files modified
extensions/adblock/extension.vala (+1/-1)
extensions/adblock/updater.vala (+19/-16)
To merge this branch: bzr merge lp:~gue5t/midori/adblock-crashes
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+283732@code.launchpad.net

Commit message

Fix crashes caused by out-of-bounds indexing in adblock

Description of the change

Pretty self-explanatory. In updater.vala, we rearrange control flow a little, so give that a bit of review. But it looks right to me and fixes the crashes without regressing any behavior.

The fixed israellist crash can be tested with the adblock subscription list https://raw.githubusercontent.com/ABPIsrael/EasyListHebrew/aebe4846c689c473e8dde278393f1d99b653d97c/EasyListHebrew.txt which is the last commit before the date format was fixed upstream.

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) wrote :

I would suggest adding this unusual date string to our tests examples.

 Otherwise the change looks sensible.

Revision history for this message
gue5t gue5t (gue5t) wrote :

It looks like our test infrastructure for extensions is rather badly broken. I'm trying to fix that at <https://code.launchpad.net/%7Egue5t/midori/adblock-crashes/+merge/283732>.

Revision history for this message
gue5t gue5t (gue5t) wrote :
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/adblock/extension.vala'
2--- extensions/adblock/extension.vala 2016-01-10 18:53:56 +0000
3+++ extensions/adblock/extension.vala 2016-01-23 21:38:31 +0000
4@@ -263,7 +263,7 @@
5 string[]? domains = null;
6 string domain = Midori.URI.parse_hostname (uri, null);
7 string[] subdomains = domain.split (".");
8- if (subdomains == null)
9+ if (subdomains == null || subdomains.length == 0)
10 return null;
11 int cnt = subdomains.length - 1;
12 var subdomain = new StringBuilder (subdomains[cnt]);
13
14=== modified file 'extensions/adblock/updater.vala'
15--- extensions/adblock/updater.vala 2014-07-17 04:35:03 +0000
16+++ extensions/adblock/updater.vala 2016-01-23 21:38:31 +0000
17@@ -100,27 +100,30 @@
18 y = int.parse(date_parts[0]);
19 d = int.parse(date_parts[2]);
20 }
21+ last_updated = new DateTime.local (y, m, d, h, min, 0.0);
22 } else { /* Date in a form of: 20 Mar 2012 12:34 */
23 string[] parts = last_mod_meta.split (" ", 4);
24- /* contains time part ? */
25- if (parts[3] != null && parts[3].contains (":")) {
26- string[] time_parts = parts[3].split (":", 2);
27- h = int.parse(time_parts[0]);
28- min = int.parse(time_parts[1]);
29- }
30+ if (parts.length >= 3) {
31+ /* contains time part ? */
32+ if (parts.length >= 4 && parts[3].contains (":")) {
33+ string[] time_parts = parts[3].split (":", 2);
34+ h = int.parse(time_parts[0]);
35+ min = int.parse(time_parts[1]);
36+ }
37
38- m = get_month_from_string (parts[1]);
39- if (parts[2].length == 4) {
40- y = int.parse(parts[2]);
41- d = int.parse(parts[0]);
42- } else {
43- y = int.parse(parts[0]);
44- d = int.parse(parts[2]);
45+ m = get_month_from_string (parts[1]);
46+ if (parts[2].length == 4) {
47+ y = int.parse(parts[2]);
48+ d = int.parse(parts[0]);
49+ } else {
50+ y = int.parse(parts[0]);
51+ d = int.parse(parts[2]);
52+ }
53+ last_updated = new DateTime.local (y, m, d, h, min, 0.0);
54 }
55 }
56-
57- last_updated = new DateTime.local (y, m, d, h, min, 0.0);
58- } else {
59+ }
60+ if (last_updated == null) {
61 /* FIXME: use file modification date if there's no update header
62 try {
63 string modified = FileAttribute.TIME_MODIFIED;

Subscribers

People subscribed via source and target branches

to all changes: