NetBSD Problem Report #1356

From gnats  Mon Aug 14 14:05:57 1995
Received: from Collatz.McRCIM.McGill.EDU (root@Collatz.McRCIM.McGill.EDU [132.206.78.1]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id OAA01015 for <gnats-bugs@gnats.netbsd.org>; Mon, 14 Aug 1995 14:05:53 -0400
Message-Id: <199508141805.OAA03530@Collatz.McRCIM.McGill.EDU>
Date: Mon, 14 Aug 1995 14:05:44 -0400
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
Reply-To: mouse@Collatz.McRCIM.McGill.EDU
To: gnats-bugs@gnats.netbsd.org
Subject: [dM] join can coredump
X-Send-Pr-Version: 3.2

>Number:         1356
>Category:       bin
>Synopsis:       [dM] join can coredump
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 14 14:20:01 +0000 1995
>Closed-Date:    Thu Feb 08 18:20:49 +0000 1996
>Last-Modified:  Thu Feb 08 18:22:41 +0000 1996
>Originator:     der Mouse
>Release:        -current as of August 11th
>Organization:
	Dis-
>Environment:
	SPARC IPC, but it's machine-independent
>Description:
	join can coredump by calling strcmp() with a nil pointer, if an
	input line contains exactly one field too few for the -j
	option's field to be present.  The problem appears to be that
	cmp() uses < rather than <= when comparing field numbers
	against field counts.  (I conjecture someone forgot which
	numbers were 0-origin and which 1-origin.)
>How-To-Repeat:
	% cat > z.1
	a b
	c d
	^D
	% cat > z.2
	a
	e d
	^D
	% join -j 2 z.1 z.2
	Segmentation fault
>Fix:
	This seems to stop the coredumping, though join still seems to
	misbehave a little; for example, the example above produces no
	output, rather than the "d c e" line that it seems to me it
	should.

*** /sources/working-usr-src/usr.bin/join/join.c	Tue May 30 08:49:41 1995
--- join.c	Mon Aug 14 13:53:36 1995
***************
*** 356,364 ****
  	LINE *lp1, *lp2;
  	u_long fieldno1, fieldno2;
  {
! 	if (lp1->fieldcnt < fieldno1)
  		return (lp2->fieldcnt < fieldno2 ? 0 : 1);
! 	if (lp2->fieldcnt < fieldno2)
  		return (-1);
  	return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2]));
  }
--- 356,364 ----
  	LINE *lp1, *lp2;
  	u_long fieldno1, fieldno2;
  {
! 	if (lp1->fieldcnt <= fieldno1)
  		return (lp2->fieldcnt < fieldno2 ? 0 : 1);
! 	if (lp2->fieldcnt <= fieldno2)
  		return (-1);
  	return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2]));
  }

					der Mouse

			    mouse@collatz.mcrcim.mcgill.edu
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mycroft 
State-Changed-When: Thu Feb 8 13:20:49 EST 1996 
State-Changed-Why:  
Fixed. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.