From nobody@FreeBSD.org  Wed Sep 10 15:26:44 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6456D1065671
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Sep 2008 15:26:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5151A8FC1E
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Sep 2008 15:26:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m8AFQiBV082062
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Sep 2008 15:26:44 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m8AFQhC6082061;
	Wed, 10 Sep 2008 15:26:43 GMT
	(envelope-from nobody)
Message-Id: <200809101526.m8AFQhC6082061@www.freebsd.org>
Date: Wed, 10 Sep 2008 15:26:43 GMT
From: Anatoly Borodin <anatoly.borodin@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: fsck_msdosfs may crash
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         127270
>Category:       bin
>Synopsis:       fsck_msdosfs(8) may crash if BytesPerSec is zero
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 10 15:30:01 UTC 2008
>Closed-Date:    
>Last-Modified:  Fri Sep 24 20:51:41 UTC 2010
>Originator:     Anatoly Borodin
>Release:        7.1-PRERELEASE
>Organization:
>Environment:
FreeBSD hp.home 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Mon Sep  1 16:07:24 EEST 2008     anatoly.borodin@gmail.com:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
I use some FAT32 filesystem from a file image. It has errors, so I tried to check it with fsck_msdosfs /dev/md0 and got this:

** /dev/md0
Floating exception (core dumped)

I compiled fsck_msdosfs with debug information and found the faulty code block at /usr/src/sbin/fsck_msdosfs/boot.c:174

        boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1)
            / boot->BytesPerSec
            + boot->ResSectors
            + boot->FATs * boot->FATsecs
            - CLUST_FIRST * boot->SecPerClust;

It fails because in my case boot->BytesPerSec == 0. IMHO such condition should be checked, fixed in the FS, but not crashed.

>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Fri Sep 24 20:51:15 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127270 
>Unformatted:
