NetBSD Problem Report #8215

Received: (qmail 2938 invoked from network); 17 Aug 1999 03:44:44 -0000
Message-Id: <199908170344.WAA12031@guild.plethora.net>
Date: Mon, 16 Aug 1999 22:44:40 -0500
From: seebs@plethora.net
Sender: seebs@guild.plethora.net
Reply-To: seebs@plethora.net
To: gnats-bugs@gnats.netbsd.org
Subject: mount_portal/pt_filter.c assumes size_t is signed int

>Number:         8215
>Category:       bin
>Synopsis:       pt_filter.c uses %d to print out result of strlen
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 16 20:50:02 +0000 1999
>Closed-Date:    Tue Aug 17 15:11:01 +0000 1999
>Last-Modified:  Tue Aug 17 15:11:43 +0000 1999
>Originator:     Seebs
>Release:        Aug 16 1999
>Organization:
>Environment:
System: NetBSD gandalf.plethora.net 1.4J NetBSD 1.4J (GANDALF) #0: Mon Aug 16 14:51:06 CDT 1999 seebs@gandalf.plethora.net:/usr/src/sys/arch/alpha/compile/GANDALF alpha


>Description:
	pt_filter.c fails to compile because -Wall catches two errors
>How-To-Repeat:
	'make build'
>Fix:

My suggestion: size_t is some unsigned type, and canonically (although maybe
not here) no larger than 'unsigned long', so we cast to that type and print
it.  'size_t' should not be bigger than long, and if it is, well, 4GB strings
are rare, and we might as well write the canonical ANSI code, even if it
may eventually fail on an oddly-designed system.

*** pt_filter.c.orig	Mon Aug 16 22:40:18 1999
--- pt_filter.c	Mon Aug 16 22:41:02 1999
***************
*** 144,151 ****
  	fill_cmd(v + 2, path, cmd, FILTER_CMD_SIZE);
  	if (strlen(cmd) >= FILTER_CMD_SIZE) {
  		syslog(LOG_WARNING,
! 		    "Warning:  potential overflow on string!  Length was %d\n",
! 		    strlen(cmd));
  		return -1;
  	}
  #ifdef DEBUG
--- 144,151 ----
  	fill_cmd(v + 2, path, cmd, FILTER_CMD_SIZE);
  	if (strlen(cmd) >= FILTER_CMD_SIZE) {
  		syslog(LOG_WARNING,
! 		    "Warning:  potential overflow on string!  Length was %lu\n",
! 		    (unsigned long) strlen(cmd));
  		return -1;
  	}
  #ifdef DEBUG
***************
*** 203,210 ****
  	fill_cmd(v + 2, path, cmd, FILTER_CMD_SIZE);
  	if (strlen(cmd) >= FILTER_CMD_SIZE) {
  		syslog(LOG_WARNING,
! 		    "Warning:  potential overflow on string!  Length was %d\n",
! 		    strlen(cmd));
  		return -1;
  	}
  	fp = popen(cmd, "w");
--- 203,210 ----
  	fill_cmd(v + 2, path, cmd, FILTER_CMD_SIZE);
  	if (strlen(cmd) >= FILTER_CMD_SIZE) {
  		syslog(LOG_WARNING,
! 		    "Warning:  potential overflow on string!  Length was %lu\n",
! 		    (unsigned long) strlen(cmd));
  		return -1;
  	}
  	fp = popen(cmd, "w");
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: kleink 
State-Changed-When: Tue Aug 17 08:11:01 PDT 1999 
State-Changed-Why:  
Duplicate of bin/8214. 
>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.