*BSD News Article 5301


Return to BSD News archive

Path: sserve!manuel!munnari.oz.au!spool.mu.edu!caen!uflorida!mosquito.cis.ufl.edu!kml
From: kml@mosquito.cis.ufl.edu (Kevin Lahey)
Newsgroups: comp.unix.bsd
Subject: csh segmentation violation
Summary: bug report and fix
Message-ID: <37095@uflorida.cis.ufl.edu>
Date: 19 Sep 92 22:52:25 GMT
Sender: news@uflorida.cis.ufl.edu
Organization: Univ. of Florida CIS Dept.
Lines: 38
Nntp-Posting-Host: mosquito.cis.ufl.edu

I have run into the csh segmentation violation bug, and I was too lazy to
install the simple "alloc + 4" bugfix, so I tracked it down.  It seems to come
about whenever you are in a directory in your account which has a pathname
length which is divisable by 4, for instance,  /users/kml/g.  To test,
create such a directory, enter it, and sorta execute alot of commands.
Sooner or later, csh will die.

The fix is to add one to the space allocated for a string in the
dcanon() routine where it normalizes directory names which include
the string defined for the environment variable 'HOME'.

Have fun,

Kevin
kml@sware.com

[Apologies in advance if I mucked up the context diffs here, but I think 
you get the idea about the change...]

*** /usr/src/bin/csh/dir.c	Sat Sep 19 10:05:01 1992
--- /usr/src/bin/csh/dir.orig	Sat Sep 19 10:04:46 1992
***************
*** 876,882 ****
  	     */
  	    p2 = cp + Strlen(p2);
  	    sp = newcp = (Char *) xmalloc((size_t)
! 					  ((cc + Strlen(p2) + 1) * sizeof(Char)));
  	    while (*p1)
  		*sp++ = *p1++;
  	    while (*p2)
--- 876,882 ----
  	     */
  	    p2 = cp + Strlen(p2);
  	    sp = newcp = (Char *) xmalloc((size_t)
! 					  ((cc + Strlen(p2)) * sizeof(Char)));
  	    while (*p1)
  		*sp++ = *p1++;
  	    while (*p2)