From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TM1TO-00055X-JS for qemu-devel@nongnu.org; Wed, 10 Oct 2012 14:57:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TM1TI-000570-N4 for qemu-devel@nongnu.org; Wed, 10 Oct 2012 14:57:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TM1TI-00056w-FE for qemu-devel@nongnu.org; Wed, 10 Oct 2012 14:57:32 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9AIvVoR000608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Oct 2012 14:57:31 -0400 Message-ID: <5075C519.30204@redhat.com> Date: Wed, 10 Oct 2012 14:57:29 -0400 From: Jeff Cody MIME-Version: 1.0 References: <37ca1a150224c144f9329fc8408f78c388f50a02.1349848348.git.jcody@redhat.com> <5075BADF.2070402@redhat.com> <5075BE97.1070407@redhat.com> <5075BFBA.8020902@redhat.com> In-Reply-To: <5075BFBA.8020902@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_find_backing_image compare canonical filenames Reply-To: jcody@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org On 10/10/2012 02:34 PM, Eric Blake wrote: > On 10/10/2012 12:29 PM, Jeff Cody wrote: > >>> That's a LOT of stack space, which risks stack overflow, will mostly be >>> unused, and still doesn't work if you have super-deep hierarchies larger >>> than PATH_MAX. Would you be better off using realpath(,NULL) for its >>> allocating semantics, and then free()ing the results? >>> >> >> That is the main reason I changed it from being a recursive function, to >> an iterative one. >> >> Do we know that realpath(,NULL) behaves the same on all platforms? > > Gnulib lists the following platforms as mis-handling NULL: > Mac OS X 10.5, FreeBSD 6.4, OpenBSD 4.4, Solaris 10. > >> >> We had a thread back in April that touched on the use of realpath, and >> concerns were raised then that realpath(,NULL) was not necessarily safe >> across all OSes: >> >> https://lists.gnu.org/archive/html/qemu-devel/2012-04/msg01417.html > > In fact, that message points out an even more insidious portability bug > in your algorithm: on Solaris 10, realpath("relative", buffer) leaves > buffer containing "relative" rather than an absolute name, but your > algorithm depends on matching absolute names. I don't know if we port > qemu to Solaris 10, but it's worth considering my question back in that > thread - does glib provide us a more portable function for converting a > relative name into a canonical path that is guaranteed to work everywhere? > We are already relying on realpath() in block.c. So rather than making this patch series much more complicated for a minor fix, I think that if there are concerns about realpath() on other OSes such as Solaris 10, then those concerns should be addressed in a separate patch series. >> >> That said, if there is concern over the stack usage, to be safe I can >> manually g_malloc() each array. > > g_malloc() would solve the stack size concern, but not the Solaris 10 > relative name bug. >