[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Possibly wrong string comparisons in SVN

From: Branko ─îibej <brane_at_xbc.nu>
Date: 2004-10-26 09:26:10 CEST

Roland Ruedenauer wrote:

>There seem to be some places in the SVN code where inadvertendly a
>string prefix match is performed where a full match was desired.
>
>1) libsvn_ra_local/split_url.c line 64
>
> if ((strncmp (hostname, "localhost", 9) != 0))
>
>2) libsvn_repos/fs-wrap.c line 330 and 332
>
> /* Only svn:author and svn:date are fetchable. */
> if ((strncmp (propname, SVN_PROP_REVISION_AUTHOR,
> strlen(SVN_PROP_REVISION_AUTHOR)) != 0)
> && (strncmp (propname, SVN_PROP_REVISION_DATE,
> strlen(SVN_PROP_REVISION_DATE)) != 0))
> *value_p = NULL;
>
>
Look again. We can't use strcmp in those places because we're looking at
a substring in a larger string. And you'll notice that the length of the
"prefix" for strncmp is always the same as the length of the string
we're comparig with.

>Other places?
>
>
Probably, but they're all correct (I hope :-).

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Oct 26 09:26:48 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.