Subject: Re: bin/29972 :cpio --version memory faults
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Kailash Sethuraman <hsaliak@kasba.ath.cx>
List: netbsd-bugs
Date: 04/15/2005 12:46:02
The following reply was made to PR bin/29972; it has been noted by GNATS.

From: Kailash Sethuraman <hsaliak@kasba.ath.cx>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/29972 :cpio --version memory faults
Date: Fri, 15 Apr 2005 20:44:29 +0800

 Hi,
 The problem seems to be that
 struct option cpio_longopts[] is not
 terminated by an element containing all zeroes.
 Thus passing any non-existant option causes cpio to seg fault.
 For example
 cpio --hsaliak will also seg fault. 
 Appending such an element removes memory faults caused by passing non existant
 options.
 I have appended a patch to options.c. 
 Hope it helps!
 
 Regards,
 Kailash
 
 ident options.c :
 options.c:
   $NetBSD: options.c,v 1.73.2.1 2004/06/22 07:28:58 tron Exp $
   $NetBSD: options.c,v 1.73.2.1 2004/06/22 07:28:58 tron Exp $
 
 --- options.c.orig	2004-06-23 08:17:21.000000000 +0800
 +++ options.c	2005-04-15 19:55:21.000000000 +0800
 @@ -1345,6 +1345,8 @@
  	{ "version",		no_argument,		0,
  						OPT_VERSION },
  #endif
 +	{0,		0,		 0,	0 },
 +	
  };
  
  /*