Commit 5e8f1f90 by wangguangchao

sysmod heap溢出问题修复提交

parent 13586e90
......@@ -53,7 +53,7 @@ void internalSetupEty()
Platform.dbCommit();
if( Platform.errorCode() > 0 )
{
Platform.sysDump( Platform.formatText( "Error occured on commiting the update of the user record.\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText() ) );
//Platform.sysDump( Platform.formatText( "Error occured on commiting the update of the user record.\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText() ) );
}
}
}
......
......@@ -13,267 +13,275 @@ init $$\ order 9000550
int ssn = 0;
String canTxt = NULLSTR;
boolean can = false;
SSNDone:
boolean SSNNewFlag = false;
SSNNewLabel:
while(true){
SSNNew:
while(true){
if( Platform.isEmpty( $\sysmod\ssn\inr ) )
{
// only on first Execution of rule try to load SPT-Inr
sptInr = Platform.lnkGetSwitch( "SPTINR" );
// only on first Execution of rule try to load a Session-Inr
ssnInr = Platform.lnkGetSwitch( "SSNINR" );
if( Platform.errorCode() == 0 )
{
// If Session-Inr is passed use this Inr as Session Id
if( Platform.compareTo(Platform.mid( ssnInr, 1, 1 ) , "A")>=0 )
{
// alphanumeric encoded SSNINR > 99999999
ssnInrNumeric = $syspth.valBase36( ssnInr );
if( ssnInrNumeric < 0 )
{
Platform.sysDump( Platform.formatText( "Invalid base 36 number '$1' passed following -SSNINR", ssnInr ) );
//return ; // #### goto SSNNew
break SSNNew;
}
Platform.setContext( tdContextSESSIONNUMBER, Platform.toString( ssnInrNumeric ) );
}
else
{
Platform.setContext( tdContextSESSIONNUMBER, ssnInr );
}
}
else
{
// If no Session-Inr is passed try to get the Session-Inr
ssn = Platform.DBGetSessionnumber();
if( Platform.errorCode() <= 0 )
{
ssnInr = Platform.toString( ssn, -8 );
if( Platform.errorCode() == tdStrBase36Encoding )
{
// alphanumeric encoding for SSNINR is ok
Platform.setErrorCode( 0, "" );
}
}
if( Platform.errorCode() > 0 )
{
$\sysmod\ssn\inr = "NO";
switch( Platform.errorCode() )
{
case 235:
canTxt = Platform.getText( #CT000176, Platform.errorCode(), Platform.getErrorText() );
break;
case 226:
canTxt = Platform.getText( #CT000178, Platform.errorCode(), Platform.getErrorText() );
break;
default:
canTxt = Platform.getText( #CT000177, Platform.errorCode(), Platform.getErrorText() );
}
if( Platform.compareTo( Platform.getContext( tdContextCLIENTSERVER ) , tdStringTRUE ) == 0 )
{
if( Platform.compareTo($\sysmod\ssn\bckgrd, "B" )== 0 )
{
Platform.setContext( "LOGFILEENTRY", canTxt );
Platform.exitSession();
}
}
can = Platform.prompt( #CT000181, canTxt );
if( can != Platform.intConvertBoolean(tdPromptCancel) )
{
Platform.exitSession();
}
//return ; // #### goto SSNNew
break SSNNew;
}
}
// After having fixed the Session-Inr lock the Session record
$\sysmod\ssn\inr = ssnInr;
Platform.dbLock( $\sysmod\ssn );
if( Platform.errorCode() > 0 )
{
$\sysmod\ssn\inr = "NO";
Platform.sysDump( Platform.formatText( "Unable to lock session ID upon start of transaction.\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText() ) );
//return ; // #### goto SSNNew
break SSNNew;
}
// Load the Session record
Platform.dbRead( $\sysmod\ssn, $\sysmod\ssn\inr.getValue(), "INR" );
if( Platform.errorCode() == tdOdbcNotFound )
{
//return ; // #### goto SSNNew
break SSNNew;
}
else
{
if( Platform.errorCode() > 0 )
{
Platform.sysDump( Platform.formatText( "Unable to read session ID upon start of transaction.\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #### goto SSNNew
break SSNNew;
}
}
}
// Check the validity of the existing SSN entry
if( ! Platform.isEmpty( $\sysmod\ssn\appsrv ) )
{
// The stored Applications server id has to fit
if( Platform.compareTo($\sysmod\ssn\appsrv.getValue(), Platform.mid( Platform.getContext( tdContextSERVERID ), 1, Platform.getAttribute( $\sysmod\ssn\appsrv.getValue(), tdAttrLength ) )) != 0 )
{
Platform.sysDump( Platform.formatText( "Inconsistent session data upon start of transaction.\nThe session record identifies the application server as $1, but it is $2.\nSession not registered.\n(Session INR used: $3)", $\sysmod\ssn\appsrv.getValue(), Platform.getContext( tdContextSERVERID ),$\sysmod\ssn\inr.getValue() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #### goto SSNNew
break SSNNew;
}
}
else
{
$\sysmod\ssn\appsrv = Platform.getContext( tdContextSERVERID );
$\sysmod\ssn\eng = Platform.fileBaseName( Platform.getContext( "ExeName" ) );
}
if( ! Platform.isEmpty( $\sysmod\ssn\apppid ) )
{
// The stored Applications server pid has to fit
if( Platform.compareTo($\sysmod\ssn\apppid.getValue(), Platform.getContext( tdContextSERVERPID )) != 0 )
{
Platform.sysDump( Platform.formatText( "Inconsistent session data upon start of transaction.\nThe session record identifies the application pid as $1, but it is $2.\nSession not registered.\n(Session INR used: $3)", $\sysmod\ssn\apppid.getValue(), Platform.getContext( tdContextSERVERPID ),$\sysmod\ssn\inr.getValue() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #### goto SSNNew
break SSNNew;
}
}
else
{
$\sysmod\ssn\apppid = Platform.getContext( tdContextSERVERPID );
}
if( ! Platform.isEmpty( $\sysmod\ssn\usr ) )
{
// The stored Userid has to fit
if( Platform.compareTo(Platform.toUpper( $\sysmod\ssn\usr.getValue() ), Platform.toUpper( Platform.getLoginUser() )) != 0 )
{
Platform.sysDump( Platform.formatText( "Inconsistent session data upon start of transaction.\nThe session record identifies the user as $1, but it is $2.\nSession not registered.\n(Session INR used: $3)", $\sysmod\ssn\usr.getValue(), Platform.getLoginUser(), $\sysmod\ssn\inr.getValue() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #### goto SSNNew
break SSNNew;
}
// to set an potential foldover user-id
$\sysmod\ssn\usr = Platform.getLoginUser();
}
else
{
$\sysmod\ssn\usr = Platform.getLoginUser();
}
// store information about the last start of a transaction
$\sysmod\ssn\lstdattim = Platform.toDay();
$\sysmod\ssn\lstfrm = Platform.fileBaseName( Platform.getTransName() );
// set status to application (database updates have been executed in this session)
// or to executing (active session with no database updates up to now)
if( !( Platform.compareTo($\sysmod\ssn\sta, "A" )== 0) )
{
$\sysmod\ssn\sta = "X";
}
// if an SSN record is reused (`inherit` or reinit/reload during debugging), set additionally
if( ! Platform.isEmpty( ssnInr ) )
{
$\sysmod\ssn\dissrv = Platform.getContext( tdContextCLIENTID ) + "-" + Platform.getClientType();
$\sysmod\ssn\dispid = Platform.getContext( tdContextCLIENTPID );
$\sysmod\ssn\eng = Platform.fileBaseName( Platform.getContext( "ExeName" ) );
if( Platform.compareTo( Platform.getContext( tdContextBATCHMODE ) , tdStringTRUE ) == 0 )
{
$\sysmod\ssn\bckgrd.setValue ( "B" );
}
else
{
$\sysmod\ssn\bckgrd.setValue ( "F" );
}
}
// update an existing SSN entry
if( Platform.compareTo($\sysmod\ssn\inr.getValue(), "NO") != 0 )
{
Platform.sdbUpdate( $\sysmod\ssn );
if( Platform.errorCode() > 0 )
{
Platform.sysDump( Platform.formatText( "Unable to update session record upon start of a transaction.\n(Session INR used: $3)\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText(), $\sysmod\ssn\inr.getValue() ) );
}
}
//return ; // #### goto SSNDone
break SSNDone;
if( Platform.isEmpty( $\sysmod\ssn\inr ) )
{
// only on first Execution of rule try to load SPT-Inr
sptInr = Platform.lnkGetSwitch( "SPTINR" );
// only on first Execution of rule try to load a Session-Inr
ssnInr = Platform.lnkGetSwitch( "SSNINR" );
if( Platform.errorCode() == 0 )
{
// If Session-Inr is passed use this Inr as Session Id
if( Platform.compareTo(Platform.mid( ssnInr, 1, 1 ) , "A")>=0 )
{
// alphanumeric encoded SSNINR > 99999999
ssnInrNumeric = $syspth.valBase36( ssnInr );
if( ssnInrNumeric < 0 )
{
Platform.sysDump( Platform.formatText( "Invalid base 36 number '$1' passed following -SSNINR", ssnInr ) );
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
Platform.setContext( tdContextSESSIONNUMBER, Platform.toString( ssnInrNumeric ) );
}
//------------------------
// #### label SSNNew
// Initial settings of a new session record
$\sysmod\ssn\begdattim = Platform.toDay();
$\sysmod\ssn\dissrv = Platform.getContext( tdContextCLIENTID ) + "-" + Platform.getClientType();
$\sysmod\ssn\dispid = Platform.getContext( tdContextCLIENTPID );
$\sysmod\ssn\eng = Platform.fileBaseName( Platform.getContext( "ExeName" ) );
$\sysmod\ssn\appsrv = Platform.getContext( tdContextSERVERID );
$\sysmod\ssn\apppid = Platform.getContext( tdContextSERVERPID );
// store information about the last start of a transaction
$\sysmod\ssn\lstdattim = $\sysmod\ssn\begdattim;
$\sysmod\ssn\lstfrm = Platform.fileBaseName( Platform.getTransName() );
$\sysmod\ssn\usr = Platform.getLoginUser();
$\sysmod\ssn\sta = "X";
Platform.clear( $\sysmod\ssn\enddattim );
int err = 0;
String errTxt = NULLSTR;
if( Platform.compareTo($\sysmod\ssn\inr.getValue(), "NO") != 0 )
else
{
Platform.dbInsert( $\sysmod\ssn );
if( Platform.errorCode() > 0 )
Platform.setContext( tdContextSESSIONNUMBER, ssnInr );
}
}
else
{
// If no Session-Inr is passed try to get the Session-Inr
ssn = Platform.DBGetSessionnumber();
if( Platform.errorCode() <= 0 )
{
ssnInr = Platform.toString( ssn, -8 );
if( Platform.errorCode() == tdStrBase36Encoding )
{
$\sysmod\ssn\inr = "NO";
if( Platform.errorCode() == 271 )
{
Platform.sysDump( Platform.formatText( "Licensed user count of $1 sessions exceeded", Platform.getContext( "MAXUSERCOUNT" ) ) );
}
else
{
err = Platform.errorCode();
errTxt = Platform.getErrorText();
msg = Platform.formatText( "Unable to create session record upon start of session.\n(Error=$1 $2)", err, errTxt );
if( ! IsAdministrator || Platform.compareTo(Platform.getInitialTransaction(), Platform.toUpper( Platform.getTransName() )) != 0 )
{
Platform.sysDump( msg );
}
}
// alphanumeric encoding for SSNINR is ok
Platform.setErrorCode( 0, "" );
}
}
if( Platform.compareTo( $\sysmod\ssn\inr , "NO" ) == 0 && IsAdministrator && Platform.compareTo( Platform.getInitialTransaction() , Platform.toUpper( Platform.getTransName() ) ) == 0 )
if( Platform.errorCode() > 0 )
{
if( ! Platform.isEmpty( msg ) )
$\sysmod\ssn\inr = "NO";
switch( Platform.errorCode() )
{
case 235:
canTxt = Platform.getText( #CT000176, Platform.errorCode(), Platform.getErrorText() );
break;
case 226:
canTxt = Platform.getText( #CT000178, Platform.errorCode(), Platform.getErrorText() );
break;
default:
canTxt = Platform.getText( #CT000177, Platform.errorCode(), Platform.getErrorText() );
}
if( Platform.compareTo( Platform.getContext( tdContextCLIENTSERVER ) , tdStringTRUE ) == 0 )
{
if( Platform.compareTo($\sysmod\ssn\bckgrd, "B" )== 0 )
{
Platform.setContext( "LOGFILEENTRY", canTxt );
Platform.exitSession();
}
}
can = Platform.prompt( #CT000181, canTxt );
if( can != Platform.intConvertBoolean(tdPromptCancel) )
{
msg = msg + "\r\n";
Platform.exitSession();
}
Platform.dbCommit();
msg = msg + "Administration transaction SYSADM will be launched now.";
Platform.message( "$1", msg );
Platform.chain( "SYSADM" );
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
// Only when in foreground and only on first start check the remaining time of the security key
String endStr = NULLSTR;
String endDatStr = NULLSTR;
Date endDat = null;
int remDay = 0;
if( Platform.compareTo($\sysmod\ssn\bckgrd, "F" )== 0 )
}
// After having fixed the Session-Inr lock the Session record
$\sysmod\ssn\inr = ssnInr;
Platform.dbLock( $\sysmod\ssn );
if( Platform.errorCode() > 0 )
{
$\sysmod\ssn\inr = "NO";
Platform.sysDump( Platform.formatText( "Unable to lock session ID upon start of transaction.\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText() ) );
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
// Load the Session record
Platform.dbRead( $\sysmod\ssn, $\sysmod\ssn\inr.getValue(), "INR" );
if( Platform.errorCode() == tdOdbcNotFound )
{
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
else
{
if( Platform.errorCode() > 0 )
{
endStr = Platform.getIniStr( "SECKEY.INI", "TRACO", "EndDate" );
endDatStr = Platform.mid( endStr, 7, 2 ) + "/" + Platform.mid( endStr, 5, 2 ) + "/" + Platform.mid( endStr, 1, 4 );
endDat = Platform.parseDate( endDatStr );
// If the content is no valid date just do not warn and ignor the error
if( Platform.errorCode() == 0 )
Platform.sysDump( Platform.formatText( "Unable to read session ID upon start of transaction.\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
}
}
// Check the validity of the existing SSN entry
if( ! Platform.isEmpty( $\sysmod\ssn\appsrv ) )
{
// The stored Applications server id has to fit
if( Platform.compareTo($\sysmod\ssn\appsrv.getValue(), Platform.mid( Platform.getContext( tdContextSERVERID ), 1, Platform.getAttribute( $\sysmod\ssn\appsrv.getValue(), tdAttrLength ) )) != 0 )
{
Platform.sysDump( Platform.formatText( "Inconsistent session data upon start of transaction.\nThe session record identifies the application server as $1, but it is $2.\nSession not registered.\n(Session INR used: $3)", $\sysmod\ssn\appsrv.getValue(), Platform.getContext( tdContextSERVERID ),$\sysmod\ssn\inr.getValue() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
}
else
{
$\sysmod\ssn\appsrv = Platform.getContext( tdContextSERVERID );
$\sysmod\ssn\eng = Platform.fileBaseName( Platform.getContext( "ExeName" ) );
}
if( ! Platform.isEmpty( $\sysmod\ssn\apppid ) )
{
// The stored Applications server pid has to fit
if( Platform.compareTo($\sysmod\ssn\apppid.getValue(), Platform.getContext( tdContextSERVERPID )) != 0 )
{
Platform.sysDump( Platform.formatText( "Inconsistent session data upon start of transaction.\nThe session record identifies the application pid as $1, but it is $2.\nSession not registered.\n(Session INR used: $3)", $\sysmod\ssn\apppid.getValue(), Platform.getContext( tdContextSERVERPID ),$\sysmod\ssn\inr.getValue() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
}
else
{
$\sysmod\ssn\apppid = Platform.getContext( tdContextSERVERPID );
}
if( ! Platform.isEmpty( $\sysmod\ssn\usr ) )
{
// The stored Userid has to fit
if( Platform.compareTo(Platform.toUpper( $\sysmod\ssn\usr.getValue() ), Platform.toUpper( Platform.getLoginUser() )) != 0 )
{
Platform.sysDump( Platform.formatText( "Inconsistent session data upon start of transaction.\nThe session record identifies the user as $1, but it is $2.\nSession not registered.\n(Session INR used: $3)", $\sysmod\ssn\usr.getValue(), Platform.getLoginUser(), $\sysmod\ssn\inr.getValue() ) );
$\sysmod\ssn\inr = "NO";
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNNew
SSNNewFlag = true;
break SSNNewLabel;
}
// to set an potential foldover user-id
$\sysmod\ssn\usr = Platform.getLoginUser();
}
else
{
$\sysmod\ssn\usr = Platform.getLoginUser();
}
// store information about the last start of a transaction
$\sysmod\ssn\lstdattim = Platform.toDay();
$\sysmod\ssn\lstfrm = Platform.fileBaseName( Platform.getTransName() );
// set status to application (database updates have been executed in this session)
// or to executing (active session with no database updates up to now)
if( !( Platform.compareTo($\sysmod\ssn\sta, "A" )== 0) )
{
$\sysmod\ssn\sta = "X";
}
// if an SSN record is reused (`inherit` or reinit/reload during debugging), set additionally
if( ! Platform.isEmpty( ssnInr ) )
{
$\sysmod\ssn\dissrv = Platform.getContext( tdContextCLIENTID ) + "-" + Platform.getClientType();
$\sysmod\ssn\dispid = Platform.getContext( tdContextCLIENTPID );
$\sysmod\ssn\eng = Platform.fileBaseName( Platform.getContext( "ExeName" ) );
if( Platform.compareTo( Platform.getContext( tdContextBATCHMODE ) , tdStringTRUE ) == 0 )
{
$\sysmod\ssn\bckgrd.setValue ( "B" );
}
else
{
$\sysmod\ssn\bckgrd.setValue ( "F" );
}
}
// update an existing SSN entry
if( Platform.compareTo($\sysmod\ssn\inr.getValue(), "NO") != 0 )
{
Platform.sdbUpdate( $\sysmod\ssn );
if( Platform.errorCode() > 0 )
{
Platform.sysDump( Platform.formatText( "Unable to update session record upon start of a transaction.\n(Session INR used: $3)\n(Error=$1 $2)", Platform.errorCode(), Platform.getErrorText(), $\sysmod\ssn\inr.getValue() ) );
}
}
break SSNNewLabel;
}
//return ; // #######TODO 改写 LABEL与GOTO #### goto SSNDone
//------------------------
// #######TODO 改写 LABEL与GOTO #### label SSNNew
if(SSNNewFlag){
// Initial settings of a new session record
$\sysmod\ssn\begdattim = Platform.toDay();
$\sysmod\ssn\dissrv = Platform.getContext( tdContextCLIENTID ) + "-" + Platform.getClientType();
$\sysmod\ssn\dispid = Platform.getContext( tdContextCLIENTPID );
$\sysmod\ssn\eng = Platform.fileBaseName( Platform.getContext( "ExeName" ) );
$\sysmod\ssn\appsrv = Platform.getContext( tdContextSERVERID );
$\sysmod\ssn\apppid = Platform.getContext( tdContextSERVERPID );
// store information about the last start of a transaction
$\sysmod\ssn\lstdattim = $\sysmod\ssn\begdattim;
$\sysmod\ssn\lstfrm = Platform.fileBaseName( Platform.getTransName() );
$\sysmod\ssn\usr = Platform.getLoginUser();
$\sysmod\ssn\sta = "X";
Platform.clear( $\sysmod\ssn\enddattim );
int err = 0;
String errTxt = NULLSTR;
if( Platform.compareTo($\sysmod\ssn\inr.getValue(), "NO") != 0 )
{
Platform.dbInsert( $\sysmod\ssn );
if( Platform.errorCode() > 0 )
{
$\sysmod\ssn\inr = "NO";
if( Platform.errorCode() == 271 )
{
Platform.sysDump( Platform.formatText( "Licensed user count of $1 sessions exceeded", Platform.getContext( "MAXUSERCOUNT" ) ) );
}
else
{
remDay = Platform.diff( endDat, Platform.today() ) + 1;
if( remDay <= 10 && remDay > 0 )
err = Platform.errorCode();
errTxt = Platform.getErrorText();
msg = Platform.formatText( "Unable to create session record upon start of session.\n(Error=$1 $2)", err, errTxt );
if( ! IsAdministrator || Platform.compareTo(Platform.getInitialTransaction(), Platform.toUpper( Platform.getTransName() )) != 0 )
{
Platform.message( #CT000180, remDay );
Platform.sysDump( msg );
}
}
}
internalSetupSSN();
break SSNDone;
}
if( Platform.compareTo( $\sysmod\ssn\inr , "NO" ) == 0 && IsAdministrator && Platform.compareTo( Platform.getInitialTransaction() , Platform.toUpper( Platform.getTransName() ) ) == 0 )
{
if( ! Platform.isEmpty( msg ) )
{
msg = msg + "\r\n";
}
Platform.dbCommit();
msg = msg + "Administration transaction SYSADM will be launched now.";
Platform.message( "$1", msg );
Platform.chain( "SYSADM" );
}
// Only when in foreground and only on first start check the remaining time of the security key
String endStr = NULLSTR;
String endDatStr = NULLSTR;
Date endDat = null;
int remDay = 0;
if( Platform.compareTo($\sysmod\ssn\bckgrd, "F" )== 0 )
{
endStr = Platform.getIniStr( "SECKEY.INI", "TRACO", "EndDate" );
endDatStr = Platform.mid( endStr, 7, 2 ) + "/" + Platform.mid( endStr, 5, 2 ) + "/" + Platform.mid( endStr, 1, 4 );
endDat = Platform.parseDate( endDatStr );
// If the content is no valid date just do not warn and ignor the error
if( Platform.errorCode() == 0 )
{
remDay = Platform.diff( endDat, Platform.today() ) + 1;
if( remDay <= 10 && remDay > 0 )
{
Platform.message( #CT000180, remDay );
}
}
}
internalSetupSSN();
}
// #### label SSNDone
// #######TODO 改写 LABEL与GOTO #### label SSNDone
// Finally commit the database transaction handling the SSN-entry
// initialy -> creation of SSN
// all others -> update SSN with current transaction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment