[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#336636: fails on fstab line without optional fields



On Mon, Oct 31, 2005 at 08:18:47PM +0100, Jonas Smedegaard wrote:
> On Mon, 31 Oct 2005 17:37:03 +0100
> Eduard Bloch <blade@debian.org> wrote:
> 
> > What does line 6 contain?
> > 
> > none /dev/pts devpts
> > 
> > It does not have all fields but all other parsers around did not have
> > such problems, and mkinitrd.yaird should not either.
> 
> I agree. Merging with the other bugreports already filed about this
> issue.

Jonas, Erik,
this is actually one of the cases where you have to check for
$#fields<3 the proposed patch will still fail on that fstab line.
It's legal for mount to have such entries so I'd suggest decreasing that
check.

One more ancillary note: I'd chomp $line and/or remove the
LIMIT parameter in the split call, otherwise a spare and empty array
element is created... I find it misleading :) (well I also re-read the
split perldoc page and the LIMIT parameter has definitely a crazy
behaviour).
So $#fields should be < 2 (if you consider fs_mntopts optional)

Index: perl/FsTab.pm
===================================================================
--- perl/FsTab.pm	(revision 4704)
+++ perl/FsTab.pm	(working copy)
@@ -41,11 +41,12 @@
 	my $lineNo = 0;
 	while (defined (my $line = <IN>)) {
 		$lineNo++;
+		chomp $line
 		$line =~ s/^\s+//;
 		next if $line =~ /^#/;	# comment line
 		next if $line eq "";	# empty line
-		my @fields = split (/\s+/, $line, 999);
-		if ($#fields < 6) {
+		my @fields = split (/\s+/, $line);
+		if ($#fields < 2) {
 			# no test for extra fields;
 			# the mount command allows that.
 			Base::fatal ("malformed line in $name:$lineNo");

-- 
mattia
:wq!

Attachment: signature.asc
Description: Digital signature


Reply to: