Can not login on Mail.ru and qiwi.ru in Firefox 3.6.17/3.5.19

RESOLVED FIXED

Status

()

Core
Networking: Cookies
--
blocker
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Alexander L. Slovesnik, Assigned: Ehsan)

Tracking

(4 keywords)

unspecified
regression, top100, verified1.9.1, verified1.9.2
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(blocking1.9.2 .18+, status1.9.2 .18-fixed, blocking1.9.1 .19+, status1.9.1 .19-fixed)

Details

(URL)

Attachments

(2 attachments, 6 obsolete attachments)

(Reporter)

Description

6 years ago
I've got a report that users can not login on Mail.ru and qiwi.ru with 3.5.19 and 3.6.17 builds ( ftp://ftp.mozilla.org/pub/firefox/nightly/3.6.17-candidates/build2/win32/ru/Firefox%20Setup%203.6.17.exe and ftp://ftp.mozilla.org/pub/firefox/nightly/3.5.19-candidates/build1/win32/ru/Firefox%20Setup%203.5.19.exe ). It somehow connected with changes in cookies handling in these builds.
I verified that with Firefox 3.6.17 candidate build I cannot login on Mail.ru web-interface. It works in Firefox 3.6.16. 
I've looked at logs and found only one changeset that change something about cookies - http://hg.mozilla.org/releases/mozilla-1.9.1/rev/2b48d65b67c9

Mail.ru is largest e-mail provider in Russia (more than 50 millions visitor per month). IMHO this should block.
If someone needs test account in Mail.ru, I will be happy to provide one.

Comment 1

6 years ago
Reproduced with:
Mozilla/5.0 (X11; U; Linux i686 (x86_64); ru; rv:1.9.2.17) Gecko/20110414 Firefox/3.6.17

WFM with:
Mozilla/5.0 (X11; U; Linux i686 (x86_64); ru; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

Comment 2

6 years ago
(In reply to comment #1)
> Reproduced with:
(on mail.ru)
(Reporter)

Comment 3

6 years ago
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2011-03-30-03-mozilla-1.9.2/firefox-3.6.17pre.en-US.linux-i686.tar.bz2 - works
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2011-04-02-03-mozilla-1.9.2/firefox-3.6.17pre.en-US.linux-i686.tar.bz2 - fails

Regression range - http://hg.mozilla.org/releases/mozilla-1.9.2/pushloghtml?fromchange=59e645275feb&tochange=5db56d0cfa3b
(Reporter)

Comment 4

6 years ago
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2011-03-31-03-mozilla-1.9.2/firefox-3.6.17pre.en-US.linux-i686.tar.bz2 - works
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2011-04-01-03-mozilla-1.9.2/firefox-3.6.17pre.en-US.linux-i686.tar.bz2 - fails

Regression range - http://hg.mozilla.org/releases/mozilla-1.9.2/pushloghtml?fromchange=33488621d2a4&tochange=a0c692da4524
(Reporter)

Updated

6 years ago
Keywords: regression, top100
:(

Posting about this to release-drivers.
Alexander: could you please email me  the info for a test account on mail.ru?
Assignee: nobody → ehsan
Blocks: 616264
(Reporter)

Comment 7

6 years ago
(In reply to comment #6)
> Alexander: could you please email me  the info for a test account on mail.ru?

Sent.
Firefox 4.0 works on mail.ru? It contains a fix for the same bug which is why we thought it was safe, but maybe the branch version has a specific problem.

Updated

6 years ago
blocking1.9.1: ? → .19+
blocking1.9.2: ? → .17+
(Reporter)

Comment 9

6 years ago
(In reply to comment #8)
> Firefox 4.0 works on mail.ru? It contains a fix for the same bug which is why
> we thought it was safe, but maybe the branch version has a specific problem.
According to comment 1 it works on 4.0.1.
(Reporter)

Comment 10

6 years ago
Just checked - WFM on http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/4.0.1-candidates/build1/linux-i686/en-US/firefox-4.0.1.tar.bz2
(In reply to comment #8)
> Firefox 4.0 works on mail.ru? It contains a fix for the same bug which is why
> we thought it was safe, but maybe the branch version has a specific problem.

The mozilla-central patch and the branch patches were totally different.  This is only a problem on stable branches.  I'm trying to figure out why...
So, I have a seemingly safe fix at hand, which I'll attach shortly.

Daniel recommends us that for 1.9.2.17 and 1.9.1.19, we should probably just back out bug 616264, and try to get it in the next time, along with this fix.  I'll do the necessary backouts.
Created attachment 526830 [details] [diff] [review]
1.9.2 patch
Attachment #526830 - Flags: review?(dwitte)
Created attachment 526842 [details] [diff] [review]
1.9.2 patch

Actually, it's best to add the correct length checking too, to make sure that nextDot[1] is not past our string buffer.
Attachment #526830 - Attachment is obsolete: true
Attachment #526830 - Flags: review?(dwitte)
Attachment #526842 - Flags: review?(dwitte)
Created attachment 526843 [details] [diff] [review]
1.9.1 patch

Mostly the same as the 1.9.2 patch, but applying on 1.9.1, and also making sure that the test passes (since NetUtils doesn't exist on 1.9.1).
Attachment #526843 - Flags: review?(dwitte)
This can block the next dot-release.
blocking1.9.1: .19+ → ?
blocking1.9.2: .17+ → ?
Created attachment 526847 [details] [diff] [review]
Trunk patch (test only)

The lesson that trunk can take from this is the test case, I guess (since this bug doesn't exist on trunk).
Attachment #526847 - Flags: review?(dwitte)
I assume we're planning on rebuilding 1.9.2, at least, for this.
(In reply to comment #18)
> I assume we're planning on rebuilding 1.9.2, at least, for this.

Christian told me that we are, yes.  I've landed the backouts earlier today, FWIW.

Comment 20

6 years ago
Comment on attachment 526842 [details] [diff] [review]
1.9.2 patch

Is 
(nextDot < end && *(nextDot + 1) == '\0')
required in the conditional check?

This evaluates true if the character after a '.' is '\0' or the second character after the initial '.' is '\0'. For the former case, I believe strchr() handles it, due to returning NULL after not finding '.' . 

The latter only applies in the first iteration of the loop. There shouldn't be a problem if the string is something like ".\0." since *currentDot will evaluate to FALSE in the ?: . There is a small difference in that the loop iterates one more time with nextDot = nsnull.
I see you landed this on 1.9.1 as well, Dan.

Comment 22

6 years ago
I confirm this bug with firefox-3.6.17 (linux)
(In reply to comment #20)
> Comment on attachment 526842 [details] [diff] [review]
>   --> https://bugzilla.mozilla.org/attachment.cgi?id=526842
> 1.9.2 patch
> 
> Is 
> (nextDot < end && *(nextDot + 1) == '\0')
> required in the conditional check?
> 
> This evaluates true if the character after a '.' is '\0' or the second
> character after the initial '.' is '\0'. For the former case, I believe
> strchr() handles it, due to returning NULL after not finding '.' . 

I added |nextDot < end| because otherwise *(nextDot+1) could read memory not part of the string.  What this check effectively tests is whether there is a null character after nextDot.

Comment 24

6 years ago
(In reply to comment #23)
> (In reply to comment #20)
> > Comment on attachment 526842 [details] [diff] [review]
>
> I added |nextDot < end| because otherwise *(nextDot+1) could read memory not
> part of the string.  What this check effectively tests is whether there is a
> null character after nextDot.

Thanks for the clarification
David pinged me about this on IRC, which caused me to document why I added the length checks in these patches.

Originally I ported the first version of the patch (without the |nextDot < end| checks) to 1.9.1, and I saw an existing test under extensions/cookie failing.  I investigated that under the debugger, and the values of currentDot and nextDot were in such a way that made this length check necessary.  I don't remember the exact details at all, and unfortunately I don't have my 1.9.{1,2} object directories around any more, but if you're curious, you can follow my footsteps as I laid out here and see what was breaking under 1.9.1, which caused me to add the length checks.
(In reply to comment #25)
> David pinged me about this on IRC, which caused me to document why I added the
> length checks in these patches.

And here's the rest of the story, courtesy of David!


dchan
grr curiosity got the best of me
dchan
looking at 1.9.1 code
ehsan
heh
dchan
there appears to be a path for fileURIs
dchan
where an empty host can get by
ehsan
this rings a bell
ehsan
yeah, maybe it was a file URI
dchan
then you insert . in front
dchan
currentDot = '.'
dchan
nextDot = '\0'
dchan
nextDot + 1 off the string
ehsan
yes
ehsan
which would fail http://mxr.mozilla.org/mozilla1.9.1/source/extensions/cookie/test/unit/test_bug526789.js#65
ehsan
:)
blocking 1.9.2/1.9.1 per comment 19, and fixed by backout of bug 616264

http://hg.mozilla.org/releases/mozilla-1.9.2/rev/1a8da3d914c3 (default)
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/fab6db5c327d (relbranch)
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/9e0d3f6ee9af (default)
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/b2756532de0f (relbranch)

This regression bug is "fixed". It would be best to track the "fix bug 616264 correctly" patch in that other bug since that's not how we're fixing the regression. If for some reason you need new patches we can put those in the other bug, otherwise no need to duplicate them.
Status: NEW → RESOLVED
blocking1.9.1: ? → .19+
blocking1.9.2: ? → .17+
Last Resolved: 6 years ago
status1.9.1: --- → .19-fixed
status1.9.2: --- → .17-fixed
Resolution: --- → FIXED
(In reply to comment #27)
> This regression bug is "fixed". It would be best to track the "fix bug 616264
> correctly" patch in that other bug since that's not how we're fixing the
> regression. If for some reason you need new patches we can put those in the
> other bug, otherwise no need to duplicate them.

I'll keep my patches in this bug, and will just apply them on top of the patches in bug 616264 when they get reviewed.  This will make Dan's job as the reviewer much easier.
I've verified this fix in build 2 of 1.9.1.19 and build 3 of 1.9.2.17 (and against earlier builds) using a mail.ru account that I created for myself.
Keywords: verified1.9.1, verified1.9.2
Dan: ping?

Comment 31

6 years ago
Pong. :( I'll take a look at this on Sunday!

Comment 32

6 years ago
Comment on attachment 526847 [details] [diff] [review]
Trunk patch (test only)

r=dwitte
Attachment #526847 - Flags: review?(dwitte) → review+

Comment 33

6 years ago
Comment on attachment 526842 [details] [diff] [review]
1.9.2 patch

>diff --git a/netwerk/cookie/src/nsCookieService.cpp b/netwerk/cookie/src/nsCookieService.cpp
>--- a/netwerk/cookie/src/nsCookieService.cpp
>+++ b/netwerk/cookie/src/nsCookieService.cpp
>@@ -1284,16 +1284,17 @@ nsCookieService::GetCookieInternal(nsIUR

>   const char *currentDot = hostFromURI.get();
>   const char *nextDot = currentDot + 1;
>+  const char *end = currentDot + (hostFromURI.Length() - 1);

So for a string 'foo', 'end' now points to the last character 'o'...

>@@ -1338,17 +1339,17 @@ nsCookieService::GetCookieInternal(nsIUR

>-    if (!nextDot || *(nextDot + 1) == '.')
>+    if (!nextDot || (nextDot < end && *(nextDot + 1) == '\0'))
>       break;

Which means the test 'nextDot < end && *(nextDot + 1) == '\0'' will never evaluate true.

I think you either want 'end' to be pointing to the null, or use an '<=' test here? Since the intent of this test is to break out if there's a '.' at the end of the string; but not if 'nextDot' actually is the end of the string, which happens for file:// URIs.

Does that sound right?
Yes, that makes sense.  I'll submit new patches in a moment.  Sorry for my delay.
Created attachment 537679 [details] [diff] [review]
1.9.2 patch
Attachment #526842 - Attachment is obsolete: true
Attachment #526842 - Flags: review?(dwitte)
Attachment #537679 - Flags: review?(dwitte)
Created attachment 537680 [details] [diff] [review]
1.9.1 patch
Attachment #526843 - Attachment is obsolete: true
Attachment #526843 - Flags: review?(dwitte)
Attachment #537680 - Flags: review?(dwitte)
Created attachment 537681 [details] [diff] [review]
1.9.2 patch

This time it's the right patch!
Attachment #537679 - Attachment is obsolete: true
Attachment #537679 - Flags: review?(dwitte)
Attachment #537681 - Flags: review?(dwitte)
Attachment #537681 - Flags: approval1.9.2.18?
Comment on attachment 537680 [details] [diff] [review]
1.9.1 patch

So long, 1.9.1!  You were a cute little stable branch.  Your memory will stay with us.
Attachment #537680 - Attachment is obsolete: true
Attachment #537680 - Flags: review?(dwitte)
Trunk test case pushed to cedar: http://hg.mozilla.org/projects/cedar/rev/53abbc401888
Created attachment 537686 [details] [diff] [review]
1.9.2 patch

Without the unnecessary cruft.
Attachment #537686 - Flags: review?(dwitte)
Attachment #537686 - Flags: approval1.9.2.18?
Attachment #537681 - Attachment is obsolete: true
Attachment #537681 - Flags: review?(dwitte)
Attachment #537681 - Flags: approval1.9.2.18?

Comment 41

6 years ago
Comment on attachment 537686 [details] [diff] [review]
1.9.2 patch

Review of attachment 537686 [details] [diff] [review]:
-----------------------------------------------------------------

Ship it!
Attachment #537686 - Flags: review?(dwitte) → review+

Updated

6 years ago
Attachment #537686 - Flags: approval1.9.2.18? → approval1.9.2.18+
Landed for 1.9.2.18:

http://hg.mozilla.org/releases/mozilla-1.9.2/rev/bb935ffe5ff1
Test case in m-c:
http://hg.mozilla.org/mozilla-central/rev/53abbc401888
Flags: in-testsuite+
blocking1.9.2: .17+ → .18+
status1.9.2: .17-fixed → .18-fixed

Updated

6 years ago
Depends on: 667087
No longer depends on: 667087
Depends on: 667087
You need to log in before you can comment on or make changes to this bug.