This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rcs 5.8-1 checks out wrong version of file when using similar mark symbols


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]