From 9d58ffd009da110c9e2533004a8e904ec83002ca Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 27 Aug 2012 15:27:12 +0000 Subject: [PATCH] 2012-08-27 17:26 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/src/rtl/fstemp.c ! added protection against possible buffer overflow * enable mkstemps() for GLIBC 2.12 and higher * harbour/src/compiler/harbour.y ! added missing ';' at the end of C code - newer bisons do not add them automatically --- harbour/ChangeLog | 9 +++++++++ harbour/src/compiler/harbour.y | 2 +- harbour/src/rtl/fstemp.c | 25 +++++++++++++++---------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6e3fba5e86..cef70e8b2c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2012-08-27 17:26 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/src/rtl/fstemp.c + ! added protection against possible buffer overflow + * enable mkstemps() for GLIBC 2.12 and higher + + * harbour/src/compiler/harbour.y + ! added missing ';' at the end of C code - newer bisons + do not add them automatically + 2012-08-26 23:22 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/listbox.prg + Extended: method :addItem( cText, qImage ) in XbpListBox() class. diff --git a/harbour/src/compiler/harbour.y b/harbour/src/compiler/harbour.y index 0f7fecc495..8f3700cb3f 100644 --- a/harbour/src/compiler/harbour.y +++ b/harbour/src/compiler/harbour.y @@ -1073,7 +1073,7 @@ CodeBlock : BlockHead ExpList : Expression { $$ = hb_compExprNewList( $1, HB_COMP_PARAM ); } | ExpList ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); } -PareExpList : '(' ExpList ')' { $$ = $2 } +PareExpList : '(' ExpList ')' { $$ = $2; } ; PareExpListAlias : PareExpList ALIASOP diff --git a/harbour/src/rtl/fstemp.c b/harbour/src/rtl/fstemp.c index 50bda3427b..6b026612a9 100644 --- a/harbour/src/rtl/fstemp.c +++ b/harbour/src/rtl/fstemp.c @@ -78,11 +78,14 @@ #if ( defined( HB_OS_LINUX ) && ( !defined( __WATCOMC__ ) || __WATCOMC__ >= 1280 ) ) || \ defined( HB_OS_BSD ) || defined( HB_OS_DARWIN ) || defined( HB_OS_SUNOS ) - #define HB_HAS_MKSTEMP - #if ( defined( HB_OS_BSD ) && !defined( __NetBSD__ ) ) || \ - defined( HB_OS_DARWIN ) - #define HB_HAS_MKSTEMPS - #endif +# define HB_HAS_MKSTEMP +# if ( defined( HB_OS_BSD ) && !defined( __NetBSD__ ) ) || \ + defined( HB_OS_DARWIN ) || \ + ( defined( HB_OS_LINUX ) && \ + ( defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \ + ( defined( __GLIBC_PREREQ ) && __GLIBC_PREREQ( 2, 12 ) ) ) +# define HB_HAS_MKSTEMPS +# endif #endif #if !defined( HB_USE_LARGEFILE64 ) && defined( HB_OS_UNIX ) @@ -162,11 +165,12 @@ HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * if( pszName[ 0 ] != '\0' ) { - int len = ( int ) strlen( pszName ); - if( pszName[ len - 1 ] != HB_OS_PATH_DELIM_CHR ) + iLen = ( int ) strlen( pszName ); + if( pszName[ iLen - 1 ] != HB_OS_PATH_DELIM_CHR && + iLen < HB_PATH_MAX - 1 ) { - pszName[ len ] = HB_OS_PATH_DELIM_CHR; - pszName[ len + 1 ] = '\0'; + pszName[ iLen ] = HB_OS_PATH_DELIM_CHR; + pszName[ iLen + 1 ] = '\0'; } } @@ -174,7 +178,8 @@ HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * hb_strncat( pszName, pszPrefix, HB_PATH_MAX - 1 ); iLen = ( int ) strlen( pszName ); - if( iLen > ( HB_PATH_MAX - 1 ) - 6 ) + if( iLen > ( HB_PATH_MAX - 1 ) - 6 - + ( pszExt ? ( int ) strlen( pszExt ) : 0 ) ) { fd = FS_ERROR; break;