Bug 324983 (MONO82314) - IsolatedStorageFileStreams over rooted paths throw UnauthorizedAccessException
Summary: IsolatedStorageFileStreams over rooted paths throw UnauthorizedAccessException
Status: RESOLVED FIXED
Alias: MONO82314
Product: Mono: Class Libraries
Classification: Mono
Component: CORLIB (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords: easy_fix
Depends on:
Blocks:
 
Reported: 2007-08-04 00:09 UTC by Jay Miller
Modified: 2007-11-06 18:37 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Test case (273 bytes, text/plain)
2007-08-04 00:10 UTC, Thomas Wiest
Details
Proposed patch: remove the root characters from the path before Combine()ing (and a unit test). (1.61 KB, patch)
2007-08-04 00:11 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:46:56 UTC


---- Reported by jnmiller@cryptofreak.org 2007-08-03 17:09:30 MST ----

Description of Problem:

With the latest out of SVN, IsolatedStorageFileStreams over rooted paths
throw UnauthorizedAccessException.  This does not happen when using the MS
library.

The problem is that Mono's ISFS path creator uses Path.Combine() without
regard to the requested path's content.  Path.Combine() in turn returns
only the second argument when that argument is a rooted path.  ISFS
therefore attempts to create its IS file off of the root directory which
is, of course, unauthorized.


Steps to reproduce the problem:
1. ISFS fs = new ISFS("/rootpath", FileMode.Create);


Actual Results:

Unhandled Exception: System.UnauthorizedAccessException: Access to the path
"rootpath" is denied.
  at System.IO.FileStream..ctor (System.String name, FileMode mode,
FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous,
FileOptions options) [0x00000] 
  at System.IO.FileStream..ctor (System.String name, FileMode mode,
FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync,
Boolean anonymous) [0x00000] 
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor
(System.String path, FileMode mode, FileAccess access, FileShare share,
Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] 
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor
(System.String path, FileMode mode) [0x00000] 
  at (wrapper remoting-invoke-with-check)
System.IO.IsolatedStorage.IsolatedStorageFileStream:.ctor
(string,System.IO.FileMode)
  at Test.Test.Main (System.String[] args) [0x00000] 


Expected Results:

Success.


How often does this happen? 

Always!


Additional Information:

I have included a patch for ISFS.cs and a unit test to cover this minor
issue.  I also included a simple test program that looks the same as the
unit test.



---- Additional Comments From jnmiller@cryptofreak.org 2007-08-03 17:10:17 MST ----

Created an attachment (id=172413)
Test case




---- Additional Comments From jnmiller@cryptofreak.org 2007-08-03 17:11:31 MST ----

Created an attachment (id=172414)
Proposed patch: remove the root characters from the path before Combine()ing (and a unit test).


Imported an attachment (id=172413)
Imported an attachment (id=172414)

Unknown operating system unknown. Setting to default OS "Other".

Comment 1 Sebastien Pouliot 2007-11-06 18:37:27 UTC
Patch applied (r89015/89016)
Thanks!