From: Ian Jackson Subject: Re: [PATCH 15/18] xenstore: New function xs_path_is_subpath Date: Mon, 12 Dec 2011 12:08:12 +0000 Message-ID: <20197.61100.1047.581173@mariner.uk.xensource.com> References: <1323456877-15315-1-git-send-email-ian.jackson@eu.citrix.com> <1323456877-15315-16-git-send-email-ian.jackson@eu.citrix.com> <1323463786.20936.19.camel@dagon.hellion.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1323463786.20936.19.camel@dagon.hellion.org.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [Xen-devel] [PATCH 15/18] xenstore: New function xs_path_is_subpath"): > On Fri, 2011-12-09 at 18:54 +0000, Ian Jackson wrote: > > + if (childlen > parentlen && child[parentlen] != '/') > > + return false; > > It took me a second to figure that this last statement was preventing > false positives from sibling directories where one is a substring of the > other. Worth a comment? Probably, yes. > Doesn't the correctness of this depend on whether parent has a trailing > slash or not though? We don't allow trailing slashes. They don't work in xenstore operations. However, there is one exception: "/". If parent is "/" the algorithm is wrong. So docs/misc/xenstore.txt needs updating to clarify the former and my new function needs the latter fixing. These are the perils of taking code that was correct in situ and making a general function out of it, I guess ... Ian.