Bug 3219 - Mono.Unix.UnixDriveInfo.GetDrives: NullReferenceException when parsing fstab
Summary: Mono.Unix.UnixDriveInfo.GetDrives: NullReferenceException when parsing fstab
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.POSIX ()
Version: unspecified
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-02-03 08:57 UTC by Michal Srb
Modified: 2012-02-04 09:09 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Check fs.fs_file for null before calling any methods on it. (514 bytes, patch)
2012-02-03 08:57 UTC, Michal Srb

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Michal Srb 2012-02-03 08:57:29 UTC
Created attachment 1315 [details]
Check fs.fs_file for null before calling any methods on it.

Hi, I found that in case /etc/fstab contains line with one word only (which is invalid entry, I know). It makes Mono.Unix.UnixDriveInfo.GetDrives throw NullReferenceException.

It is because the structure returned from Native.Syscall.getfsent() has fs_file member set to null.

Of course, one shouldn't have invalid entries in /etc/fstab, but I assume mono libraries shouldn't fail on it when the rest of system can ignore it. This issue caused rug (package manager) on SLES10 to crash.

Attaching simple suggested fix.
Comment 1 Zoltan Varga 2012-02-04 09:09:41 UTC
Applied to HEAD/2.10.