To close the loop on this, this is fixed as eb3a1f67 by using a dynamically 
growable std::wstring instead of preallocating a "large enough" buffer.

Thanks for the report and the great diagnosis.
_fish

On Apr 22, 2013, at 11:09 AM, Ben Franksen <ben.frank...@online.de> wrote:

> Nicholas Burlett wrote:
>> On Apr 22, 2013, at 10:36 AM, Ben Franksen <ben.franksen-
> bgeptl67xyczqb+pc5n...@public.gmane.org> wrote:
>>> So, it appears that the locals fs (ext4) has a sane limit but sshfs does 
>>> not.
>> 
>> That makes some sense… sshfs is probably trying to avoid a round-trip to 
> the server and is just reporting MAX_LONG. 
>> 
>> I'm not a core fish contributor, 
> 
> Me neither, so please check the proposed patch below for validity (or ignore 
> at your leisure).
> 
>> but I expect that given this scenario, the code should be checking for ln 
> <0 || ln > MAX_FILE_LENGTH:
>> 
>>           if (ln < 0 || ln > MAX_FILE_LENGTH)
>>               ln = MAX_FILE_LENGTH;
> 
> Yes, or just forget about the whole pathconf cruft and use the maximum 
> (MAX_FILE_LENGTH=1024). It's not /that/ much memory (about 4k at the max) 
> and it's a temporary scratch area anyway, so why bother. This is my current 
> "fix":
> 
> ben@sarun[2]: .../src/fish-shell > git diff   
> diff --git a/wildcard.cpp b/wildcard.cpp
> index 6bd0153..dca8fb6 100644
> --- a/wildcard.cpp
> +++ b/wildcard.cpp
> @@ -903,7 +903,6 @@ static int wildcard_expand_internal(const wchar_t *wc,
>           The maximum length of a file element
>         */
>         long ln=MAX_FILE_LENGTH;
> -        char * narrow_dir_string = wcs2str(dir_string);
> 
>         /*
>           In recursive mode, we look through the directory twice. If
> @@ -911,21 +910,6 @@ static int wildcard_expand_internal(const wchar_t *wc,
>         */
>         rewinddir(dir);
> 
> -        if (narrow_dir_string)
> -        {
> -            /*
> -               Find out how long the filename can be in a worst case
> -               scenario
> -            */
> -            ln = pathconf(narrow_dir_string, _PC_NAME_MAX);
> -
> -            /*
> -              If not specified, use som large number as fallback
> -            */
> -            if (ln < 0)
> -                ln = MAX_FILE_LENGTH;
> -            free(narrow_dir_string);
> -        }
>         new_dir= (wchar_t *)malloc(sizeof(wchar_t)*(base_len+ln+2));
> 
>         wc_str = wc_end?wcsndup(wc, wc_end-wc):wcsdup(wc);
> 
> 
> (this, BTW, also avoids the temporary allocation for narrow_dir_string.
> 
> Cheers
> -- 
> Ben Franksen
> ()  ascii ribbon campaign - against html e-mail 
> /\  www.asciiribbon.org   - against proprietary attachm€nts
> 
> 
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to