From blank@sliphost37.uni-trier.de  Fri Jun 19 04:37:47 1998
Received: from sliphost37.uni-trier.de (root@sliphost37.uni-trier.de [136.199.240.37])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA21571
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Jun 1998 04:37:42 -0700 (PDT)
          (envelope-from blank@sliphost37.uni-trier.de)
Received: (from blank@localhost)
	by sliphost37.uni-trier.de (8.8.8/8.8.8) id KAA01446;
	Fri, 19 Jun 1998 10:12:56 +0200 (CEST)
	(envelope-from blank)
Message-Id: <199806190812.KAA01446@sliphost37.uni-trier.de>
Date: Fri, 19 Jun 1998 10:12:56 +0200 (CEST)
From: blank@fox.uni-trier.de (Sascha Blank)
Reply-To: blank@fox.uni-trier.de (Sascha Blank)
To: FreeBSD-gnats-submit@freebsd.org
Subject: Minor flaw in fdformat
X-Send-Pr-Version: 3.2

>Number:         6995
>Category:       bin
>Synopsis:       [patch] Minor flaw in fdformat
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 19 04:40:03 PDT 1998
>Closed-Date:    Thu Jun 1 19:09:19 PDT 2000
>Last-Modified:  Thu Jun 01 19:10:08 PDT 2000
>Originator:     Sascha Blank
>Release:        FreeBSD 2.2.6-STABLE i386
>Organization:
>Environment:

A very recent FreeBSD 2.2-STABLE system.  As the file
/usr/src/usr.sbin/fdformat/fdformat.c has no RCS identifier, I use the
file size and md5 sum instead.

% ls -l /usr/src/usr.sbin/fdformat/fdformat.c
-rw-r--r--  1 blank  blank  8709 17 Jun 10:26 fdformat.c
% md5 /usr/src/usr.sbin/fdformat/fdformat.c
MD5 (fdformat.c) = 8046542311740db36fad2401e6a76bcc

>Description:

fdformat prints a line of hyphens that it turns into status characters
one by one to show how far the formatting process has already proceeded.
It always prints exactly 40 hyphens assuming that the disk to be
formatted will have 80 tracks.  But this assumption is wrong if you
format a disk using a higher capacity like 1720k (which goes by 82
tracks).  In this case 41 status characters will be printed over the 40
hyphens printed at the beginning.

>How-To-Repeat:

Format a disk using the 1720k option of fdformat and watch the output,
when the last tracks are formatted.

>Fix:
	
The calculation how many status characters are needed is already
correct, so we use the same algorithm to calculate how many hyphens
should be printed at the beginning.

This flaw is likely to be present in 3.0-CURRENT as well.

*** fdformat.c.ctm	Wed Jun 17 10:26:24 1998
--- fdformat.c	Wed Jun 17 10:30:10 1998
***************
*** 299,306 ****
  	 * Formatting.
  	 */
  	if(!quiet) {
- 		printf("Processing ----------------------------------------\r");
  		printf("Processing ");
  		fflush(stdout);
  	}
  
--- 299,311 ----
  	 * Formatting.
  	 */
  	if(!quiet) {
  		printf("Processing ");
+ 		for (track = 0; track < fdt.tracks * fdt.heads; track++) {
+ 			if (!((track + 1) % tracks_per_dot)) {
+ 				putchar('-');
+ 			}
+ 		}
+ 		printf("\rProcessing ");
  		fflush(stdout);
  	}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Sat Jun 27 02:50:22 PDT 1998 
State-Changed-Why:  
awaiting committer 
State-Changed-From-To: suspended->closed 
State-Changed-By: nrahlstr 
State-Changed-When: Thu Jun 1 19:09:19 PDT 2000 
State-Changed-Why:  
Fixed by kato in revision 1.10 of fdformat.c.  Thanks. 


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