From 37271cec25f2cf78da8878602b7e444a57957f1c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 25 Jan 2010 14:24:54 +0000 Subject: [PATCH] 2010-01-25 15:23 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/utils/netiocmd.prg ! Fixed remote execution protection to work even when the source was compiled from another directory. ; QUESTION: Is there a better way to make this kind of protection? Current system will break if the source filename of the caller happens to change in the future. * contrib/hbnetio/utils/netiosrv.prg + Show internal error and quit and if above self-protection got broken for some reason. * utils/hbmk2/hbmk2.prg ! Fixed entry function detection builting project in different than current dir, possibly also in -inc mode. [TOMERGE 2.0] --- harbour/ChangeLog | 18 ++++++++++++++++++ harbour/contrib/hbnetio/utils/netiocmd.prg | 5 ++++- harbour/contrib/hbnetio/utils/netiosrv.prg | 5 +++++ harbour/utils/hbmk2/hbmk2.prg | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2a5ac0365f..15ec83e868 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,24 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-25 15:23 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbnetio/utils/netiocmd.prg + ! Fixed remote execution protection to work even when + the source was compiled from another directory. + ; QUESTION: Is there a better way to make this kind of + protection? Current system will break if + the source filename of the caller happens to + change in the future. + + * contrib/hbnetio/utils/netiosrv.prg + + Show internal error and quit and if above self-protection + got broken for some reason. + + * utils/hbmk2/hbmk2.prg + ! Fixed entry function detection builting project in + different than current dir, possibly also in -inc mode. + [TOMERGE 2.0] + 2010-01-25 13:23 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * ChangeLog + Added TOMERGE to /INSTALL doc modifications. diff --git a/harbour/contrib/hbnetio/utils/netiocmd.prg b/harbour/contrib/hbnetio/utils/netiocmd.prg index 773290965b..3dc8e393a6 100644 --- a/harbour/contrib/hbnetio/utils/netiocmd.prg +++ b/harbour/contrib/hbnetio/utils/netiocmd.prg @@ -16,8 +16,11 @@ FUNCTION hbnetiosrv_LoadCmds( bQuit, bShowInfo ) LOCAL hCmds + LOCAL cName + /* We add here a little validation to ensure that we can not be hacked. [vailtom] */ - IF Lower( ProcName( 1 ) + "-" + ProcFile( 1 ) ) != "main-netiosrv.prg" + hb_FNameSplit( ProcFile( 1 ), NIL, @cName ) + IF Lower( ProcName( 1 ) + "-" + cName ) != "main-netiosrv" RETURN NIL ENDIF diff --git a/harbour/contrib/hbnetio/utils/netiosrv.prg b/harbour/contrib/hbnetio/utils/netiosrv.prg index 0a0a097cac..b042d2e1e6 100644 --- a/harbour/contrib/hbnetio/utils/netiosrv.prg +++ b/harbour/contrib/hbnetio/utils/netiosrv.prg @@ -138,6 +138,11 @@ PROCEDURE Main( ... ) hCommands := hbnetiosrv_LoadCmds( {|| lQuit := .T. },; /* codeblock to quit */ {|| ShowConfig( netiosrv ) } ) /* codeblock to display config both uses local vars */ + IF Empty( hCommands ) + OutStd( "Internal error", hb_osNewLine() ) + lQuit := .T. + ENDIF + /* Command prompt */ DO WHILE ! lQuit diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index bf854aacc1..59a8448191 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -3753,7 +3753,7 @@ FUNCTION hbmk( aArgs, /* @ */ lPause ) /* Do entry function detection on platform required and supported */ IF ! hbmk[ _HBMK_lDONTEXEC ] .AND. ! lStopAfterCComp .AND. l_cMAIN == NIL - tmp := iif( Lower( FN_ExtGet( hbmk[ _HBMK_cFIRST ] ) ) $ ".prg|.clp" .OR. Empty( FN_ExtGet( hbmk[ _HBMK_cFIRST ] ) ), FN_ExtSet( hbmk[ _HBMK_cFIRST ], ".c" ), hbmk[ _HBMK_cFIRST ] ) + tmp := iif( Lower( FN_ExtGet( hbmk[ _HBMK_cFIRST ] ) ) $ ".prg|.clp" .OR. Empty( FN_ExtGet( hbmk[ _HBMK_cFIRST ] ) ), FN_DirExtSet( hbmk[ _HBMK_cFIRST ], cWorkDir, ".c" ), hbmk[ _HBMK_cFIRST ] ) IF ! Empty( tmp := getFirstFunc( hbmk, tmp ) ) l_cMAIN := tmp ENDIF