zsh-workers
 help / color / mirror / code / Atom feed
* Change in glibc's strncmp -> segfault?
@ 2004-01-20  9:24 Bob Schmertz
  2004-01-20 10:57 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Schmertz @ 2004-01-20  9:24 UTC (permalink / raw)
  To: zsh-workers

Hi,

I man page for strcmp on my Linux system, and it doesn't say anything
about the behavior of strcmp or stsrncmp when null pointers are passed. 
But sometimes you call add_match_part explicitly with NULL parameters for
the first six params.  Two of these are immediately passed into a strncmp
call.

I upgraded my glibc on my Gentoo box in the last day or two to 2.3.2-r9. 
Unfortunately, I don't know what version I had before.  From around that
time, I started getting crashes when I would tab-complete a directory
name.  I made it whole again by changing line 344 in compmatch.c
(downloaded v. 4.1.1 today) from

    if (!strncmp(l, w, wl))

to 
    if (l && !strncmp(l, w, wl))

I suppose it should really be (l && w && !strncmp(...)), on the chance
that there is somewhere that you are calling add_match_part with a null w
but a non-null l, but this fixed my immediate problem.  I have no idea if
this solution is "correct", but I hope at least I have pointed out the
right problem.

=====
Cheers,
Bob Schmertz

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Change in glibc's strncmp -> segfault?
  2004-01-20  9:24 Change in glibc's strncmp -> segfault? Bob Schmertz
@ 2004-01-20 10:57 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2004-01-20 10:57 UTC (permalink / raw)
  To: robert.schmertz, zsh-workers

Bob Schmertz wrote:
> I man page for strcmp on my Linux system, and it doesn't say anything
> about the behavior of strcmp or stsrncmp when null pointers are passed. 
> But sometimes you call add_match_part explicitly with NULL parameters for
> the first six params.  Two of these are immediately passed into a strncmp
> call.

You're right, that's weird.  I've applied your change, since it looks
like the intention is either both pointers are NULL or neither.

The author for that part of the shell went off to do some real work a
couple of years ago.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited. 
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-20 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-20  9:24 Change in glibc's strncmp -> segfault? Bob Schmertz
2004-01-20 10:57 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).