delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/03/28/05:27:25

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4F72D956.50009@lysator.liu.se>
Date: Wed, 28 Mar 2012 11:26:46 +0200
From: Peter Rosin <peda AT lysator DOT liu DOT se>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120312 Thunderbird/11.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: rcs 5.8-1 checks out wrong version of file when using similar mark symbols
References: <CAD+0NRCaKSvkoyuKgOdy6GUn98Y5Qmc++FAdyCtt41viVrS-Rw AT mail DOT gmail DOT com> <CAEhDDbApcdd7szQgjVmyCoKJkujTgAM7ytP-a0iyL1uJWnkN9g AT mail DOT gmail DOT com> <4F717637 DOT 80703 AT lysator DOT liu DOT se> <4F71791C DOT 8010707 AT lysator DOT liu DOT se> <20120328065524 DOT GA27483 AT phoenix>
In-Reply-To: <20120328065524.GA27483@phoenix>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Gary Johnson skrev 2012-03-28 08:55:
> On 2012-03-27, Peter Rosin wrote:
>> But the point still stands, don't assume the original authors were
>> idiots, and dig into the reasons for them to not having used
>> strcmp from the start.
> 
> I don't know, the "original" authors seem to have gotten it right,
> as version 5.7 works correctly on my Fedora system, and the function
> in question was added between versions 5.7 and 5.8.

What are you trying to say here?  That whoever it was that brought
rcs from 5.7 to 5.8 are a bunch of idiots?  I'm sure not, but that's
what it sounds like...

Cheech, I just said that it looked suspect that strcmp was not used
from the start and that someone needed to look at the code and double-
check if strlen/strcmp was safe to use before running full-steam into
a segfault.

So, go look at the code.  I just did, and the suggested changes are
indeed broken since the id string is *not* guaranteed to be zero-
terminated.  It appears that the original authors (of 5.8 of course,
that's the version we are discussing) are not idiots, since you can
neither use strlen on the id string nor can you use strcmp on it.

However, it seems as if d->meaningful is zero-terminated (as far as
I can tell strcmp, via the STR_SAME macro, is used on it at other
locations in the code).

So, this is probably safe for line 11:

   if ((strlen(d->meaningful) == id->size) && !strncmp(d->meaningful, id->string, id->size))

If d->meaningful is not guaranteed to be zero-terminated, this bug
is not fixable from within rev_from_symbol().

Cheers,
Peter

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019