Subject: bin/1582: Wrong conversion function used for size in mtree
To: None <gnats-bugs@gnats.netbsd.org>
From: Rolf Grossmann <grossman@kate.informatik.tu-muenchen.de>
List: netbsd-bugs
Date: 10/03/1995 22:12:11
>Number: 1582
>Category: bin
>Synopsis: Wrong conversion function used for size in mtree
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 6 12:35:01 1995
>Last-Modified:
>Originator:
>Organization:
>Release: -current
>Environment:
System: NetBSD kate 1.0A NetBSD 1.0A (TIGKI) #84: Thu Sep 14 17:29:07 MET DST 1995 grossman@kate:/export/netbsd/src/sys/arch/sparc/compile/TIGKI sparc
>Description:
When converting the argument of a size keyword to the st_size
parameter, mtree uses strtouq, which is not correct, because
the type is off_t, which is a (signed) quad.
>How-To-Repeat:
It should be obvious from reading the code. Here are the definitions:
<sys/types.h>:
typedef quad_t off_t; /* file offset */
"mtree.h":
off_t st_size; /* size */
Look at the patch below for the actual problem.
>Fix:
Index: spec.c
===================================================================
RCS file: /export/netbsd/mastersrc/netbsd/usr.sbin/mtree/spec.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 spec.c
*** spec.c 1995/04/03 16:28:51 1.1.1.2
--- spec.c 1995/10/03 21:08:48
***************
*** 211,217 ****
err("invalid link count %s", val);
break;
case F_SIZE:
! ip->st_size = strtouq(val, &ep, 10);
if (*ep)
err("invalid size %s", val);
break;
--- 211,217 ----
err("invalid link count %s", val);
break;
case F_SIZE:
! ip->st_size = strtoq(val, &ep, 10);
if (*ep)
err("invalid size %s", val);
break;
>Audit-Trail:
>Unformatted: