Boost logo

Boost-Build :

From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2008-02-01 14:24:33


   Hi Rene.

>> I'm attaching a patch to fix this so please review and grok it for me
>> to apply or apply it directly.
>
> It looks like that change introduces a buffer under-run when one passes
> in an empty string.

   Yup, you're right. Sorry. Here's a corrected patch.

   I tried playing around with the code to get it more succinct but
haven't found a way to avoid that explicitly empty/non-empty if. :-)

   Best regards,
     Jurko Gospodnetić

Index: filent.c
===================================================================
--- filent.c (revision 43047)
+++ filent.c (working copy)
@@ -87,18 +87,33 @@
         int ret;
         struct _finddata_t finfo[1];
         LIST* files = L0;
+ int d_length = strlen( d->name );
 
         memset( (char *)&f, '\0', sizeof( f ) );
         
         f.f_dir.ptr = d->name;
- f.f_dir.len = strlen(d->name);
-
+ f.f_dir.len = d_length;
+
         /* Now enter contents of directory */
 
- string_copy( filespec, *d->name ? d->name : "." );
- string_append( filespec, "/*" );
+ /* Prepare file search specification for the findfirst() API. */
+ if ( d_length == 0 )
+ string_copy( filespec, ".\\*" );
+ else
+ {
+ /*
+ * We can not simply assume the given folder name will never include
+ * its trailing path separator or otherwise we would not support the
+ * Windows root folder specified without its drive letter, i.e. '\'.
+ */
+ char trailingChar = d->name[ d_length - 1 ] ;
+ string_copy( filespec, d->name );
+ if ( ( trailingChar != '\\' ) && ( trailingChar != '/' ) )
+ string_append( filespec, "\\" );
+ string_append( filespec, "*" );
+ }
 
- if( DEBUG_BINDSCAN )
+ if ( DEBUG_BINDSCAN )
             printf( "scan directory %s\n", dir );
 
         # if defined(__BORLANDC__) && __BORLANDC__ < 0x550


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk