NetBSD Problem Report #1090

From gnats  Tue May 30 11:42:24 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id LAA12510 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Tue, 30 May 1995 11:42:23 -0700
Message-Id: <199505301842.UAA18679@piau.df.lth.se>
Date: Tue, 30 May 1995 20:42:37 +0200
From: Peter Svensson <petersv@df.lth.se>
Reply-To: petersv@df.lth.se
To: gnats-bugs@NetBSD.ORG
Subject: Lack of checking of parameters to diskpart
X-Send-Pr-Version: 3.2

>Number:         1090
>Category:       bin
>Synopsis:       diskpart doesnt check its paramters
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 30 11:50:02 +0000 1995
>Closed-Date:    Wed Jul 30 21:16:39 +0000 1997
>Last-Modified:  Wed Jul 30 21:17:36 +0000 1997
>Originator:     Peter Svensson
>Release:        950515	<NetBSD-current source date>
>Organization:
Comuter Society at Lund University and Lund Institute of Technology

>Environment:
SparcStation 1, NetBSD-current

System: NetBSD piau.df.lth.se 1.0A NetBSD 1.0A (PIAU.SCSI) #0: Sat May 27 13:38:54 MET DST 1995 root@piau.df.lth.se:/usr/src/sys/arch/sparc/compile/PIAU.SCSI sparc


>Description:
In src/usr.sbin/diskpart/diskpart.c checking for proper parameters is 
omitted for the disk type parameter. This results in a segfault as 
getdiskbyname() is called with NULL if the disk type parameter is 
omitted. 

The -s parameter also erronously increases the argc by two instead of 
decrementing it.

>How-To-Repeat:
Execute 'diskpart -d'

>Fix:
Thw following patch helped me:
(Output produced by    diff -U 2 diskpart.c diskpartfix.c)
------------------------ CUT
--- diskpart.c	Tue Apr 25 12:27:28 1995
+++ diskpartfix.c	Tue May 30 20:33:56 1995
@@ -138,7 +138,13 @@
 	if (argc > 1 && strcmp(*argv, "-s") == 0) {
 		totsize = atoi(argv[1]);
-		argc += 2, argv += 2;
+		argc -= 2, argv += 2;
+	}
+	if (argc > 0)
+		dp = getdiskbyname(*argv);
+	else {
+		fprintf(stderr,
+		    "usage: diskpart [ -p ] [ -d ] [ -s size ] disk-type\n");
+		exit(1);
 	}
-	dp = getdiskbyname(*argv);
 	if (dp == NULL) {
 		if (isatty(0))
--------------   CUT


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: perry 
State-Changed-When: Wed Jul 30 14:16:39 PDT 1997 
State-Changed-Why:  
It appears that this got fixed during various merges and changes 
over the last two years... 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.