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: <4F71791C.8010707@lysator.liu.se> Date: Tue, 27 Mar 2012 10:23:56 +0200 From: Peter Rosin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 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: <4F717637 DOT 80703 AT lysator DOT liu DOT se> In-Reply-To: <4F717637.80703@lysator.liu.se> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Peter Rosin skrev 2012-03-27 10:11: > But...careful! You have to assume that the original authors were not > idiots! Maybe the obvious strcmp was not used for a *good* reason? I > can't tell if d->meaningful is guaranteed to be zero-terminated from the > limited context, but it sure is suspect. Assuming that the original > authors were not idiots but instead made an off-by one error missing a > corner-case, the safer approach is to replace line 11 with: > > 11: if (!strncmp (d->meaningful, id->string, id->size + 1)) > > That is, if id->string is guaranteed to be zero-terminated, which is > not clear either, but perhaps easier to verify... Scratch that, including the zero-terminator in the compare doesn't work as expected if one of the strings is not zero-terminated. 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. 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