Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Issue 39275: Fixes possible crash in SessionBackend. I believe what's happening... (Closed)

Created:
11 years, 9 months ago by sky
Modified:
9 years, 7 months ago
Reviewers:
Finnur, Peter Kasting
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Fixes possible crash in SessionBackend. I believe what's happening here is we fail to create the file, and so current_session_file_.get() is NULL and we crash. current_session_file_.get() is NULL if OpenAndWriteHeader returns NULL (which is does if the full header isn't written correctly. Here's how I'm changing the code: . The file is now truncated instead of closed/reopened. Hopefully this avoids the possibility of a scanner locking the file and the delete failing. . Added a unit test for coverage of truncation. . The file is opened in exclusive access. There is no reason why a scanner should open this file. . Added null checks. BUG=8476 TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=11262

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 2

Patch Set 3 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+62 lines, -7 lines) Patch
M chrome/browser/sessions/session_backend.h View 2 chunks +13 lines, -2 lines 0 comments Download
M chrome/browser/sessions/session_backend.cc View 1 2 4 chunks +20 lines, -5 lines 0 comments Download
M chrome/browser/sessions/session_backend_unittest.cc View 2 1 chunk +29 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
sky
11 years, 9 months ago (2009-03-06 21:24:45 UTC) #1
Finnur
This looks fine. I do wonder though why we don't take an exclusive lock on ...
11 years, 9 months ago (2009-03-06 22:37:51 UTC) #2
Peter Kasting
Maybe you should comment in the code why this can be NULL?
11 years, 9 months ago (2009-03-06 22:49:56 UTC) #3
sky
I've changed the code to truncate the file if already open, which should avoid the ...
11 years, 9 months ago (2009-03-09 16:30:31 UTC) #4
Finnur
http://codereview.chromium.org/39275/diff/1002/6 File chrome/browser/sessions/session_backend.cc (right): http://codereview.chromium.org/39275/diff/1002/6#newcode338 Line 338: base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE); I would have thought that ...
11 years, 9 months ago (2009-03-09 17:36:50 UTC) #5
sky
Good call. Updated.
11 years, 9 months ago (2009-03-09 17:58:47 UTC) #6
Finnur
11 years, 9 months ago (2009-03-09 18:02:19 UTC) #7
LGTM

Powered by Google App Engine
This is Rietveld 408576698