idx int64 | func_before string | Vulnerability Classification string | vul int64 | func_after string | patch string | CWE ID string | lines_before string | lines_after string |
|---|---|---|---|---|---|---|---|---|
13,200 | void check_tmp_dir(){
#if !defined(WIN32)
if (!RmFlag) return;
const char *tmpDir = NULL;
bool newLock = param_boolean("CREATE_LOCKS_ON_LOCAL_DISK", true);
if (newLock) {
FileLock *lock = new FileLock(-1, NULL, NULL);
tmpDir = lock->GetTempPath();
delete lock;
rec_lock_cleanup(tmpDir, 3);
if (tmpDir != NULL)
delete []tmpDir;
}
#endif
}
| DoS Exec Code | 0 | void check_tmp_dir(){
#if !defined(WIN32)
if (!RmFlag) return;
const char *tmpDir = NULL;
bool newLock = param_boolean("CREATE_LOCKS_ON_LOCAL_DISK", true);
if (newLock) {
FileLock *lock = new FileLock(-1, NULL, NULL);
tmpDir = lock->GetTempPath();
delete lock;
rec_lock_cleanup(tmpDir, 3);
if (tmpDir != NULL)
delete []tmpDir;
}
#endif
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,201 | cluster_exists( int cluster )
{
return proc_exists( cluster, -1 );
}
| DoS Exec Code | 0 | cluster_exists( int cluster )
{
return proc_exists( cluster, -1 );
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,202 | get_machine_state()
{
char* state_str = NULL;
State s;
ReliSock* sock;
Daemon my_startd( DT_STARTD );
if( ! my_startd.locate() ) {
dprintf( D_ALWAYS, "Can't find local startd address.\n" );
return _error_state_;
}
if( !(sock = (ReliSock*)
my_startd.startCommand(GIVE_STATE, Stream::reli_sock, 0)) ) {
dprintf( D_ALWAYS, "Can't connect to startd at %s\n",
my_startd.addr() );
return _error_state_;
}
sock->end_of_message();
sock->decode();
if( !sock->code( state_str ) || !sock->end_of_message() ) {
dprintf( D_ALWAYS, "Can't read state/eom from startd.\n" );
free(state_str);
return _error_state_;
}
sock->close();
delete sock;
s = string_to_state( state_str );
free(state_str);
return s;
}
| DoS Exec Code | 0 | get_machine_state()
{
char* state_str = NULL;
State s;
ReliSock* sock;
Daemon my_startd( DT_STARTD );
if( ! my_startd.locate() ) {
dprintf( D_ALWAYS, "Can't find local startd address.\n" );
return _error_state_;
}
if( !(sock = (ReliSock*)
my_startd.startCommand(GIVE_STATE, Stream::reli_sock, 0)) ) {
dprintf( D_ALWAYS, "Can't connect to startd at %s\n",
my_startd.addr() );
return _error_state_;
}
sock->end_of_message();
sock->decode();
if( !sock->code( state_str ) || !sock->end_of_message() ) {
dprintf( D_ALWAYS, "Can't read state/eom from startd.\n" );
free(state_str);
return _error_state_;
}
sock->close();
delete sock;
s = string_to_state( state_str );
free(state_str);
return s;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,203 | grab_val( const char *str, const char *pattern )
{
char const *ptr;
if( (ptr = strstr(str,pattern)) ) {
return atoi(ptr + strlen(pattern) );
}
return -1;
}
| DoS Exec Code | 0 | grab_val( const char *str, const char *pattern )
{
char const *ptr;
if( (ptr = strstr(str,pattern)) ) {
return atoi(ptr + strlen(pattern) );
}
return -1;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,204 | init_params()
{
Spool = param("SPOOL");
if( Spool == NULL ) {
EXCEPT( "SPOOL not specified in config file\n" );
}
Log = param("LOG");
if( Log == NULL ) {
EXCEPT( "LOG not specified in config file\n" );
}
DaemonSockDir = param("DAEMON_SOCKET_DIR");
if( DaemonSockDir == NULL ) {
EXCEPT("DAEMON_SOCKET_DIR not defined\n");
}
char *Execute = param("EXECUTE");
if( Execute ) {
ExecuteDirs.append(Execute);
free(Execute);
Execute = NULL;
}
ExtArray<ParamValue> *params = param_all();
for( int p=params->length(); p--; ) {
char const *name = (*params)[p].name.Value();
char *tail = NULL;
if( strncasecmp( name, "SLOT", 4 ) != 0 ) continue;
strtol( name+4, &tail, 10 );
if( tail <= name || strcasecmp( tail, "_EXECUTE" ) != 0 ) continue;
Execute = param(name);
if( Execute ) {
if( !ExecuteDirs.contains( Execute ) ) {
ExecuteDirs.append( Execute );
}
free( Execute );
}
}
delete params;
if( (PreenAdmin = param("PREEN_ADMIN")) == NULL ) {
if( (PreenAdmin = param("CONDOR_ADMIN")) == NULL ) {
EXCEPT( "CONDOR_ADMIN not specified in config file" );
}
}
ValidSpoolFiles = param("VALID_SPOOL_FILES");
InvalidLogFiles = param("INVALID_LOG_FILES");
if( (MailPrg = param("MAIL")) == NULL ) {
EXCEPT ( "MAIL not specified in config file" );
}
}
| DoS Exec Code | 0 | init_params()
{
Spool = param("SPOOL");
if( Spool == NULL ) {
EXCEPT( "SPOOL not specified in config file\n" );
}
Log = param("LOG");
if( Log == NULL ) {
EXCEPT( "LOG not specified in config file\n" );
}
DaemonSockDir = param("DAEMON_SOCKET_DIR");
if( DaemonSockDir == NULL ) {
EXCEPT("DAEMON_SOCKET_DIR not defined\n");
}
char *Execute = param("EXECUTE");
if( Execute ) {
ExecuteDirs.append(Execute);
free(Execute);
Execute = NULL;
}
ExtArray<ParamValue> *params = param_all();
for( int p=params->length(); p--; ) {
char const *name = (*params)[p].name.Value();
char *tail = NULL;
if( strncasecmp( name, "SLOT", 4 ) != 0 ) continue;
strtol( name+4, &tail, 10 );
if( tail <= name || strcasecmp( tail, "_EXECUTE" ) != 0 ) continue;
Execute = param(name);
if( Execute ) {
if( !ExecuteDirs.contains( Execute ) ) {
ExecuteDirs.append( Execute );
}
free( Execute );
}
}
delete params;
if( (PreenAdmin = param("PREEN_ADMIN")) == NULL ) {
if( (PreenAdmin = param("CONDOR_ADMIN")) == NULL ) {
EXCEPT( "CONDOR_ADMIN not specified in config file" );
}
}
ValidSpoolFiles = param("VALID_SPOOL_FILES");
InvalidLogFiles = param("INVALID_LOG_FILES");
if( (MailPrg = param("MAIL")) == NULL ) {
EXCEPT ( "MAIL not specified in config file" );
}
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,205 | is_ccb_file( const char *name )
{
if( strstr(name,".ccb_reconnect") ) {
return TRUE;
}
return FALSE;
}
| DoS Exec Code | 0 | is_ccb_file( const char *name )
{
if( strstr(name,".ccb_reconnect") ) {
return TRUE;
}
return FALSE;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,206 | is_ckpt_file( const char *name )
{
if( strstr(name,"cluster") ) {
return is_v3_ckpt( name );
} else {
return is_v2_ckpt( name );
}
}
| DoS Exec Code | 0 | is_ckpt_file( const char *name )
{
if( strstr(name,"cluster") ) {
return is_v3_ckpt( name );
} else {
return is_v2_ckpt( name );
}
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,207 | is_v2_ckpt( const char *name )
{
int cluster;
int proc;
cluster = grab_val( name, "job" );
proc = grab_val( name, ".ckpt." );
if( proc < 0 ) {
return cluster_exists( cluster );
} else {
return proc_exists( cluster, proc );
}
}
| DoS Exec Code | 0 | is_v2_ckpt( const char *name )
{
int cluster;
int proc;
cluster = grab_val( name, "job" );
proc = grab_val( name, ".ckpt." );
if( proc < 0 ) {
return cluster_exists( cluster );
} else {
return proc_exists( cluster, proc );
}
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,208 | is_v3_ckpt( const char *name )
{
int cluster;
int proc;
int subproc;
cluster = grab_val( name, "cluster" );
proc = grab_val( name, ".proc" );
subproc = grab_val( name, ".subproc" );
if( proc < 0 ) {
return cluster_exists( cluster );
} else {
return proc_exists( cluster, proc );
}
}
| DoS Exec Code | 0 | is_v3_ckpt( const char *name )
{
int cluster;
int proc;
int subproc;
cluster = grab_val( name, "cluster" );
proc = grab_val( name, ".proc" );
subproc = grab_val( name, ".subproc" );
if( proc < 0 ) {
return cluster_exists( cluster );
} else {
return proc_exists( cluster, proc );
}
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,209 | is_valid_shared_exe( const char *name )
{
if ((strlen(name) < 4) || (strncmp(name, "exe-", 4) != 0)) {
return FALSE;
}
MyString path;
path.sprintf("%s/%s", Spool, name);
int count = link_count(path.Value());
if (count == 1) {
return FALSE;
}
if (count == -1) {
dprintf(D_ALWAYS, "link_count error on %s; not deleting\n", name);
}
return TRUE;
}
| DoS Exec Code | 0 | is_valid_shared_exe( const char *name )
{
if ((strlen(name) < 4) || (strncmp(name, "exe-", 4) != 0)) {
return FALSE;
}
MyString path;
path.sprintf("%s/%s", Spool, name);
int count = link_count(path.Value());
if (count == 1) {
return FALSE;
}
if (count == -1) {
dprintf(D_ALWAYS, "link_count error on %s; not deleting\n", name);
}
return TRUE;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,210 | main( int argc, char *argv[] )
{
#ifndef WIN32
install_sig_handler(SIGPIPE, SIG_IGN );
#endif
config(false,false,false);
MyName = argv[0];
myDistro->Init( argc, argv );
config();
init_params();
BadFiles = new StringList;
param_functions *p_funcs = NULL;
for( argv++; *argv; argv++ ) {
if( (*argv)[0] == '-' ) {
switch( (*argv)[1] ) {
case 'd':
Termlog = 1;
case 'v':
VerboseFlag = TRUE;
break;
case 'm':
MailFlag = TRUE;
break;
case 'r':
RmFlag = TRUE;
break;
default:
usage();
}
} else {
usage();
}
}
p_funcs = get_param_functions();
dprintf_config("TOOL", p_funcs);
if (VerboseFlag)
{
std::string szVerbose="D_FULLDEBUG";
char * pval = param("TOOL_DEBUG");
if( pval ) {
szVerbose+="|";
szVerbose+=pval;
free( pval );
}
_condor_set_debug_flags( szVerbose.c_str() );
}
dprintf( D_ALWAYS, "********************************\n");
dprintf( D_ALWAYS, "STARTING: condor_preen\n");
dprintf( D_ALWAYS, "********************************\n");
check_spool_dir();
check_execute_dir();
check_log_dir();
check_daemon_sock_dir();
check_tmp_dir();
if( !BadFiles->isEmpty() ) {
produce_output();
}
delete BadFiles;
dprintf( D_ALWAYS, "********************************\n");
dprintf( D_ALWAYS, "ENDING: condor_preen\n");
dprintf( D_ALWAYS, "********************************\n");
return 0;
}
| DoS Exec Code | 0 | main( int argc, char *argv[] )
{
#ifndef WIN32
install_sig_handler(SIGPIPE, SIG_IGN );
#endif
config(false,false,false);
MyName = argv[0];
myDistro->Init( argc, argv );
config();
init_params();
BadFiles = new StringList;
param_functions *p_funcs = NULL;
for( argv++; *argv; argv++ ) {
if( (*argv)[0] == '-' ) {
switch( (*argv)[1] ) {
case 'd':
Termlog = 1;
case 'v':
VerboseFlag = TRUE;
break;
case 'm':
MailFlag = TRUE;
break;
case 'r':
RmFlag = TRUE;
break;
default:
usage();
}
} else {
usage();
}
}
p_funcs = get_param_functions();
dprintf_config("TOOL", p_funcs);
if (VerboseFlag)
{
std::string szVerbose="D_FULLDEBUG";
char * pval = param("TOOL_DEBUG");
if( pval ) {
szVerbose+="|";
szVerbose+=pval;
free( pval );
}
_condor_set_debug_flags( szVerbose.c_str() );
}
dprintf( D_ALWAYS, "********************************\n");
dprintf( D_ALWAYS, "STARTING: condor_preen\n");
dprintf( D_ALWAYS, "********************************\n");
check_spool_dir();
check_execute_dir();
check_log_dir();
check_daemon_sock_dir();
check_tmp_dir();
if( !BadFiles->isEmpty() ) {
produce_output();
}
delete BadFiles;
dprintf( D_ALWAYS, "********************************\n");
dprintf( D_ALWAYS, "ENDING: condor_preen\n");
dprintf( D_ALWAYS, "********************************\n");
return 0;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,211 | proc_exists( int cluster, int proc )
{
ClassAd *ad;
if ((ad = GetJobAd(cluster,proc)) != NULL) {
FreeJobAd(ad);
return TRUE;
}
return FALSE;
}
| DoS Exec Code | 0 | proc_exists( int cluster, int proc )
{
ClassAd *ad;
if ((ad = GetJobAd(cluster,proc)) != NULL) {
FreeJobAd(ad);
return TRUE;
}
return FALSE;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,212 | void rec_lock_cleanup(const char *path, int depth, bool remove_self) {
#if !defined(WIN32)
FileLock *lock = NULL;
if (depth == 0) {
lock = new FileLock(path, true, true);
delete lock;
return ;
}
Directory *dir = new Directory(path);
if (dir == NULL) {
return;
}
const char *entry;
while ((entry = dir->Next()) != 0) {
if (!dir->IsDirectory() && depth > 1) { // clean up files floating around randomly -- maybe from older releases
lock = new FileLock(path, false, true);
bool result = lock->obtain(WRITE_LOCK);
if (!result) {
dprintf(D_FULLDEBUG, "Cannot lock %s\n", path);
}
int res = unlink(dir->GetFullPath());
if (res != 0) {
dprintf(D_FULLDEBUG, "Cannot delete %s (%s) \n", path, strerror(errno));
}
delete lock;
} else {
rec_lock_cleanup(dir->GetFullPath(), depth-1, true);
}
}
if (remove_self) {
int res = rmdir(path);
if (res != 0) {
dprintf(D_FULLDEBUG, "Directory %s could not be removed.\n", path);
}
}
delete dir;
#endif
}
| DoS Exec Code | 0 | void rec_lock_cleanup(const char *path, int depth, bool remove_self) {
#if !defined(WIN32)
FileLock *lock = NULL;
if (depth == 0) {
lock = new FileLock(path, true, true);
delete lock;
return ;
}
Directory *dir = new Directory(path);
if (dir == NULL) {
return;
}
const char *entry;
while ((entry = dir->Next()) != 0) {
if (!dir->IsDirectory() && depth > 1) { // clean up files floating around randomly -- maybe from older releases
lock = new FileLock(path, false, true);
bool result = lock->obtain(WRITE_LOCK);
if (!result) {
dprintf(D_FULLDEBUG, "Cannot lock %s\n", path);
}
int res = unlink(dir->GetFullPath());
if (res != 0) {
dprintf(D_FULLDEBUG, "Cannot delete %s (%s) \n", path, strerror(errno));
}
delete lock;
} else {
rec_lock_cleanup(dir->GetFullPath(), depth-1, true);
}
}
if (remove_self) {
int res = rmdir(path);
if (res != 0) {
dprintf(D_FULLDEBUG, "Directory %s could not be removed.\n", path);
}
}
delete dir;
#endif
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,213 | touched_recently(char const *fname,time_t delta)
{
StatInfo statinfo(fname);
if( statinfo.Error() != 0 ) {
return false;
}
if( abs((int)(time(NULL)-statinfo.GetModifyTime())) > delta ) {
return false;
}
return true;
}
| DoS Exec Code | 0 | touched_recently(char const *fname,time_t delta)
{
StatInfo statinfo(fname);
if( statinfo.Error() != 0 ) {
return false;
}
if( abs((int)(time(NULL)-statinfo.GetModifyTime())) > delta ) {
return false;
}
return true;
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,214 | usage()
{
fprintf( stderr, "Usage: %s [-mail] [-remove] [-verbose] [-debug]\n", MyName );
exit( 1 );
}
| DoS Exec Code | 0 | usage()
{
fprintf( stderr, "Usage: %s [-mail] [-remove] [-verbose] [-debug]\n", MyName );
exit( 1 );
}
| @@ -221,17 +221,17 @@ produce_output()
}
szTmp.sprintf("The condor_preen process has found the following stale condor files on <%s>:\n\n", get_local_hostname().Value());
- dprintf(D_ALWAYS, szTmp.Value());
+ dprintf(D_ALWAYS, "%s", szTmp.Value());
if( MailFlag ) {
fprintf( mailer, "\n" );
- fprintf( mailer, szTmp.Value());
+ fprintf( mailer, "%s", szTmp.Value());
}
for( BadFiles->rewind(); (str = BadFiles->next()); ) {
szTmp.sprintf(" %s\n", str);
- dprintf(D_ALWAYS, szTmp.Value() );
- fprintf( mailer, szTmp.Value() );
+ dprintf(D_ALWAYS, "%s", szTmp.Value() );
+ fprintf( mailer, "%s", szTmp.Value() );
}
if( MailFlag ) { | CWE-134 | null | null |
13,215 | RuntimeConfigItem() : admin(NULL), config(NULL) { }
| DoS Exec Code | 0 | RuntimeConfigItem() : admin(NULL), config(NULL) { }
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,216 | check_domain_attributes()
{
/* Make sure the FILESYSTEM_DOMAIN and UID_DOMAIN attributes
are set to something reasonable. If they're not already
defined, we default to our own full hostname. Moved this
to its own function so we're sure we have our full hostname
by the time we call this. -Derek Wright 10/20/98 */
char *uid_domain, *filesys_domain;
filesys_domain = param("FILESYSTEM_DOMAIN");
if( !filesys_domain ) {
insert( "FILESYSTEM_DOMAIN", get_local_fqdn().Value(),
ConfigTab, TABLESIZE );
extra_info->AddInternalParam("FILESYSTEM_DOMAIN");
} else {
free( filesys_domain );
}
uid_domain = param("UID_DOMAIN");
if( !uid_domain ) {
insert( "UID_DOMAIN", get_local_fqdn().Value(),
ConfigTab, TABLESIZE );
extra_info->AddInternalParam("UID_DOMAIN");
} else {
free( uid_domain );
}
}
| DoS Exec Code | 0 | check_domain_attributes()
{
/* Make sure the FILESYSTEM_DOMAIN and UID_DOMAIN attributes
are set to something reasonable. If they're not already
defined, we default to our own full hostname. Moved this
to its own function so we're sure we have our full hostname
by the time we call this. -Derek Wright 10/20/98 */
char *uid_domain, *filesys_domain;
filesys_domain = param("FILESYSTEM_DOMAIN");
if( !filesys_domain ) {
insert( "FILESYSTEM_DOMAIN", get_local_fqdn().Value(),
ConfigTab, TABLESIZE );
extra_info->AddInternalParam("FILESYSTEM_DOMAIN");
} else {
free( filesys_domain );
}
uid_domain = param("UID_DOMAIN");
if( !uid_domain ) {
insert( "UID_DOMAIN", get_local_fqdn().Value(),
ConfigTab, TABLESIZE );
extra_info->AddInternalParam("UID_DOMAIN");
} else {
free( uid_domain );
}
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,217 | check_params()
{
#if defined( HPUX )
char* tmp;
if( !(tmp = param("ARCH")) ) {
fprintf( stderr, "ERROR: %s must know if you are running "
"on an HPPA1 or an HPPA2 CPU.\n",
myDistro->Get() );
fprintf( stderr, "Normally, we look in %s for your model.\n",
"/opt/langtools/lib/sched.models" );
fprintf( stderr, "This file lists all HP models and the "
"corresponding CPU type. However,\n" );
fprintf( stderr, "this file does not exist on your machine "
"or your model (%s)\n", sysapi_uname_arch() );
fprintf( stderr, "was not listed. You should either explicitly "
"set the ARCH parameter\n" );
fprintf( stderr, "in your config source, or install the "
"sched.models file.\n" );
exit( 1 );
} else {
free( tmp );
}
#endif
}
| DoS Exec Code | 0 | check_params()
{
#if defined( HPUX )
char* tmp;
if( !(tmp = param("ARCH")) ) {
fprintf( stderr, "ERROR: %s must know if you are running "
"on an HPPA1 or an HPPA2 CPU.\n",
myDistro->Get() );
fprintf( stderr, "Normally, we look in %s for your model.\n",
"/opt/langtools/lib/sched.models" );
fprintf( stderr, "This file lists all HP models and the "
"corresponding CPU type. However,\n" );
fprintf( stderr, "this file does not exist on your machine "
"or your model (%s)\n", sysapi_uname_arch() );
fprintf( stderr, "was not listed. You should either explicitly "
"set the ARCH parameter\n" );
fprintf( stderr, "in your config source, or install the "
"sched.models file.\n" );
exit( 1 );
} else {
free( tmp );
}
#endif
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,218 | clear_config()
{
register int i;
register BUCKET *ptr = NULL;
register BUCKET *tmp = NULL;
for( i=0; i<TABLESIZE; i++ ) {
ptr = ConfigTab[i];
while( ptr ) {
tmp = ptr->next;
FREE( ptr->value );
ptr->value = NULL;
FREE( ptr->name );
ptr->name = NULL;
FREE( ptr );
ptr = tmp;
}
ConfigTab[i] = NULL;
}
if (extra_info != NULL) {
delete extra_info;
extra_info = NULL;
}
global_config_source = "";
local_config_sources.clearAll();
return;
}
| DoS Exec Code | 0 | clear_config()
{
register int i;
register BUCKET *ptr = NULL;
register BUCKET *tmp = NULL;
for( i=0; i<TABLESIZE; i++ ) {
ptr = ConfigTab[i];
while( ptr ) {
tmp = ptr->next;
FREE( ptr->value );
ptr->value = NULL;
FREE( ptr->name );
ptr->name = NULL;
FREE( ptr );
ptr = tmp;
}
ConfigTab[i] = NULL;
}
if (extra_info != NULL) {
delete extra_info;
extra_info = NULL;
}
global_config_source = "";
local_config_sources.clearAll();
return;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,219 | int compareFiles(const void *a, const void *b) {
return strcmp(*(char *const*)a, *(char *const*)b);
}
| DoS Exec Code | 0 | int compareFiles(const void *a, const void *b) {
return strcmp(*(char *const*)a, *(char *const*)b);
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,220 | config_fill_ad( ClassAd* ad, const char *prefix )
{
char *tmp;
char *expr;
StringList reqdExprs;
MyString buffer;
if( !ad ) return;
if ( ( NULL == prefix ) && get_mySubSystem()->hasLocalName() ) {
prefix = get_mySubSystem()->getLocalName();
}
buffer.sprintf( "%s_EXPRS", get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
buffer.sprintf( "%s_ATTRS", get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
if(prefix) {
buffer.sprintf( "%s_%s_EXPRS", prefix, get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
buffer.sprintf( "%s_%s_ATTRS", prefix, get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
}
if( !reqdExprs.isEmpty() ) {
reqdExprs.rewind();
while ((tmp = reqdExprs.next())) {
expr = NULL;
if(prefix) {
buffer.sprintf("%s_%s", prefix, tmp);
expr = param(buffer.Value());
}
if(!expr) {
expr = param(tmp);
}
if(expr == NULL) continue;
buffer.sprintf( "%s = %s", tmp, expr );
if( !ad->Insert( buffer.Value() ) ) {
dprintf(D_ALWAYS,
"CONFIGURATION PROBLEM: Failed to insert ClassAd attribute %s. The most common reason for this is that you forgot to quote a string value in the list of attributes being added to the %s ad.\n",
buffer.Value(), get_mySubSystem()->getName() );
}
free( expr );
}
}
/* Insert the version into the ClassAd */
ad->Assign( ATTR_VERSION, CondorVersion() );
ad->Assign( ATTR_PLATFORM, CondorPlatform() );
}
| DoS Exec Code | 0 | config_fill_ad( ClassAd* ad, const char *prefix )
{
char *tmp;
char *expr;
StringList reqdExprs;
MyString buffer;
if( !ad ) return;
if ( ( NULL == prefix ) && get_mySubSystem()->hasLocalName() ) {
prefix = get_mySubSystem()->getLocalName();
}
buffer.sprintf( "%s_EXPRS", get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
buffer.sprintf( "%s_ATTRS", get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
if(prefix) {
buffer.sprintf( "%s_%s_EXPRS", prefix, get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
buffer.sprintf( "%s_%s_ATTRS", prefix, get_mySubSystem()->getName() );
tmp = param( buffer.Value() );
if( tmp ) {
reqdExprs.initializeFromString (tmp);
free (tmp);
}
}
if( !reqdExprs.isEmpty() ) {
reqdExprs.rewind();
while ((tmp = reqdExprs.next())) {
expr = NULL;
if(prefix) {
buffer.sprintf("%s_%s", prefix, tmp);
expr = param(buffer.Value());
}
if(!expr) {
expr = param(tmp);
}
if(expr == NULL) continue;
buffer.sprintf( "%s = %s", tmp, expr );
if( !ad->Insert( buffer.Value() ) ) {
dprintf(D_ALWAYS,
"CONFIGURATION PROBLEM: Failed to insert ClassAd attribute %s. The most common reason for this is that you forgot to quote a string value in the list of attributes being added to the %s ad.\n",
buffer.Value(), get_mySubSystem()->getName() );
}
free( expr );
}
}
/* Insert the version into the ClassAd */
ad->Assign( ATTR_VERSION, CondorVersion() );
ad->Assign( ATTR_PLATFORM, CondorPlatform() );
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,221 | config_host( char* host )
{
real_config( host, 0, true );
}
| DoS Exec Code | 0 | config_host( char* host )
{
real_config( host, 0, true );
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,222 | find_file(const char *env_name, const char *file_name)
{
char* config_source = NULL;
char* env = NULL;
int fd = 0;
if( env_name && (env = getenv( env_name )) ) {
config_source = strdup( env );
StatInfo si( config_source );
switch( si.Error() ) {
case SIGood:
if( si.IsDirectory() ) {
fprintf( stderr, "File specified in %s environment "
"variable:\n\"%s\" is a directory. "
"Please specify a file.\n", env_name,
config_source );
free( config_source );
config_source = NULL;
exit( 1 );
}
return config_source;
break;
case SINoFile:
if (!is_piped_command(config_source) ||
!is_valid_command(config_source)) {
fprintf( stderr, "File specified in %s environment "
"variable:\n\"%s\" does not exist.\n",
env_name, config_source );
free( config_source );
exit( 1 );
break;
}
return config_source;
case SIFailure:
fprintf( stderr, "Cannot stat file specified in %s "
"environment variable:\n\"%s\", errno: %d\n",
env_name, config_source, si.Errno() );
free( config_source );
exit( 1 );
break;
}
}
# ifdef UNIX
if (!config_source) {
int locations_length = 4;
MyString locations[locations_length];
locations[0].sprintf( "/etc/%s/%s", myDistro->Get(), file_name );
locations[1].sprintf( "/usr/local/etc/%s", file_name );
if (tilde) {
locations[2].sprintf( "%s/%s", tilde, file_name );
}
char *globus_location;
if ((globus_location = getenv("GLOBUS_LOCATION"))) {
locations[3].sprintf( "%s/etc/%s", globus_location, file_name );
}
int ctr;
for (ctr = 0 ; ctr < locations_length; ctr++) {
if (!locations[ctr].IsEmpty()) {
config_source = strdup(locations[ctr].Value());
if ((fd = safe_open_wrapper_follow(config_source, O_RDONLY)) < 0) {
free(config_source);
config_source = NULL;
} else {
close(fd);
dprintf(D_FULLDEBUG, "Reading condor configuration "
"from '%s'\n", config_source);
break;
}
}
} // FOR
} // IF
# elif defined WIN32 // ifdef UNIX
HKEY handle;
char regKey[256];
snprintf( regKey, 256, "Software\\%s", myDistro->GetCap() );
if ( !config_source && RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey,
0, KEY_READ, &handle) == ERROR_SUCCESS ) {
char the_path[MAX_PATH];
DWORD valType;
DWORD valSize = MAX_PATH - 2;
the_path[0] = '\0';
if ( RegQueryValueEx(handle, env_name, 0,
&valType, (unsigned char *)the_path, &valSize) == ERROR_SUCCESS ) {
if ( valType == REG_SZ && the_path[0] ) {
config_source = strdup(the_path);
if ( strncmp(config_source, "\\\\", 2 ) == 0 ) {
NETRESOURCE nr;
nr.dwType = RESOURCETYPE_DISK;
nr.lpLocalName = NULL;
nr.lpRemoteName = condor_dirname(config_source);
nr.lpProvider = NULL;
if ( NO_ERROR != WNetAddConnection2(
&nr, /* NetResource */
NULL, /* password (default) */
NULL, /* username (default) */
0 /* flags (none) */
) ) {
if ( GetLastError() == ERROR_INVALID_PASSWORD ) {
WNetAddConnection2(
&nr, /* NetResource */
"", /* password (none) */
NULL, /* username (default) */
0 /* flags (none) */
);
}
}
if (nr.lpRemoteName) {
free(nr.lpRemoteName);
}
}
if( !(is_piped_command(config_source) &&
is_valid_command(config_source)) &&
(fd = safe_open_wrapper_follow( config_source, O_RDONLY)) < 0 ) {
free( config_source );
config_source = NULL;
} else {
if (fd != 0) {
close( fd );
}
}
}
}
RegCloseKey(handle);
}
# else
# error "Unknown O/S"
# endif /* ifdef UNIX / Win32 */
return config_source;
}
| DoS Exec Code | 0 | find_file(const char *env_name, const char *file_name)
{
char* config_source = NULL;
char* env = NULL;
int fd = 0;
if( env_name && (env = getenv( env_name )) ) {
config_source = strdup( env );
StatInfo si( config_source );
switch( si.Error() ) {
case SIGood:
if( si.IsDirectory() ) {
fprintf( stderr, "File specified in %s environment "
"variable:\n\"%s\" is a directory. "
"Please specify a file.\n", env_name,
config_source );
free( config_source );
config_source = NULL;
exit( 1 );
}
return config_source;
break;
case SINoFile:
if (!is_piped_command(config_source) ||
!is_valid_command(config_source)) {
fprintf( stderr, "File specified in %s environment "
"variable:\n\"%s\" does not exist.\n",
env_name, config_source );
free( config_source );
exit( 1 );
break;
}
return config_source;
case SIFailure:
fprintf( stderr, "Cannot stat file specified in %s "
"environment variable:\n\"%s\", errno: %d\n",
env_name, config_source, si.Errno() );
free( config_source );
exit( 1 );
break;
}
}
# ifdef UNIX
if (!config_source) {
int locations_length = 4;
MyString locations[locations_length];
locations[0].sprintf( "/etc/%s/%s", myDistro->Get(), file_name );
locations[1].sprintf( "/usr/local/etc/%s", file_name );
if (tilde) {
locations[2].sprintf( "%s/%s", tilde, file_name );
}
char *globus_location;
if ((globus_location = getenv("GLOBUS_LOCATION"))) {
locations[3].sprintf( "%s/etc/%s", globus_location, file_name );
}
int ctr;
for (ctr = 0 ; ctr < locations_length; ctr++) {
if (!locations[ctr].IsEmpty()) {
config_source = strdup(locations[ctr].Value());
if ((fd = safe_open_wrapper_follow(config_source, O_RDONLY)) < 0) {
free(config_source);
config_source = NULL;
} else {
close(fd);
dprintf(D_FULLDEBUG, "Reading condor configuration "
"from '%s'\n", config_source);
break;
}
}
} // FOR
} // IF
# elif defined WIN32 // ifdef UNIX
HKEY handle;
char regKey[256];
snprintf( regKey, 256, "Software\\%s", myDistro->GetCap() );
if ( !config_source && RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey,
0, KEY_READ, &handle) == ERROR_SUCCESS ) {
char the_path[MAX_PATH];
DWORD valType;
DWORD valSize = MAX_PATH - 2;
the_path[0] = '\0';
if ( RegQueryValueEx(handle, env_name, 0,
&valType, (unsigned char *)the_path, &valSize) == ERROR_SUCCESS ) {
if ( valType == REG_SZ && the_path[0] ) {
config_source = strdup(the_path);
if ( strncmp(config_source, "\\\\", 2 ) == 0 ) {
NETRESOURCE nr;
nr.dwType = RESOURCETYPE_DISK;
nr.lpLocalName = NULL;
nr.lpRemoteName = condor_dirname(config_source);
nr.lpProvider = NULL;
if ( NO_ERROR != WNetAddConnection2(
&nr, /* NetResource */
NULL, /* password (default) */
NULL, /* username (default) */
0 /* flags (none) */
) ) {
if ( GetLastError() == ERROR_INVALID_PASSWORD ) {
WNetAddConnection2(
&nr, /* NetResource */
"", /* password (none) */
NULL, /* username (default) */
0 /* flags (none) */
);
}
}
if (nr.lpRemoteName) {
free(nr.lpRemoteName);
}
}
if( !(is_piped_command(config_source) &&
is_valid_command(config_source)) &&
(fd = safe_open_wrapper_follow( config_source, O_RDONLY)) < 0 ) {
free( config_source );
config_source = NULL;
} else {
if (fd != 0) {
close( fd );
}
}
}
}
RegCloseKey(handle);
}
# else
# error "Unknown O/S"
# endif /* ifdef UNIX / Win32 */
return config_source;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,223 | find_global()
{
MyString file;
file.sprintf( "%s_config", myDistro->Get() );
return find_file( EnvGetName( ENV_CONFIG), file.Value() );
}
| DoS Exec Code | 0 | find_global()
{
MyString file;
file.sprintf( "%s_config", myDistro->Get() );
return find_file( EnvGetName( ENV_CONFIG), file.Value() );
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,224 | get_exclude_regex(Regex &excludeFilesRegex)
{
const char* _errstr;
int _erroffset;
char* excludeRegex = param("LOCAL_CONFIG_DIR_EXCLUDE_REGEXP");
if(excludeRegex) {
if (!excludeFilesRegex.compile(excludeRegex,
&_errstr, &_erroffset)) {
EXCEPT("LOCAL_CONFIG_DIR_EXCLUDE_REGEXP "
"config parameter is not a valid "
"regular expression. Value: %s, Error: %s",
excludeRegex, _errstr ? _errstr : "");
}
if(!excludeFilesRegex.isInitialized() ) {
EXCEPT("Could not init regex "
"to exclude files in %s\n", __FILE__);
}
}
free(excludeRegex);
}
| DoS Exec Code | 0 | get_exclude_regex(Regex &excludeFilesRegex)
{
const char* _errstr;
int _erroffset;
char* excludeRegex = param("LOCAL_CONFIG_DIR_EXCLUDE_REGEXP");
if(excludeRegex) {
if (!excludeFilesRegex.compile(excludeRegex,
&_errstr, &_erroffset)) {
EXCEPT("LOCAL_CONFIG_DIR_EXCLUDE_REGEXP "
"config parameter is not a valid "
"regular expression. Value: %s, Error: %s",
excludeRegex, _errstr ? _errstr : "");
}
if(!excludeFilesRegex.isInitialized() ) {
EXCEPT("Could not init regex "
"to exclude files in %s\n", __FILE__);
}
}
free(excludeRegex);
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,225 | get_tilde()
{
init_tilde();
return tilde;
}
| DoS Exec Code | 0 | get_tilde()
{
init_tilde();
return tilde;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,226 | init_config(bool wantExtraInfo /* = true */)
{
memset( (char *)ConfigTab, 0, (TABLESIZE * sizeof(BUCKET*)) );
if (wantExtraInfo) {
extra_info = new ExtraParamTable();
} else {
extra_info = new DummyExtraParamTable();
}
param_info_init();
return;
}
| DoS Exec Code | 0 | init_config(bool wantExtraInfo /* = true */)
{
memset( (char *)ConfigTab, 0, (TABLESIZE * sizeof(BUCKET*)) );
if (wantExtraInfo) {
extra_info = new ExtraParamTable();
} else {
extra_info = new DummyExtraParamTable();
}
param_info_init();
return;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,227 | init_dynamic_config()
{
static bool initialized = false;
if( initialized ) {
return;
}
enable_runtime = param_boolean( "ENABLE_RUNTIME_CONFIG", false );
enable_persistent = param_boolean( "ENABLE_PERSISTENT_CONFIG", false );
initialized = true;
if( !enable_persistent ) {
return;
}
char* tmp;
MyString filename_parameter;
filename_parameter.sprintf( "%s_CONFIG", get_mySubSystem()->getName() );
tmp = param( filename_parameter.Value() );
if( tmp ) {
toplevel_persistent_config = tmp;
free( tmp );
return;
}
tmp = param( "PERSISTENT_CONFIG_DIR" );
if( !tmp ) {
if ( get_mySubSystem()->isClient( ) || !have_config_source ) {
/*
we are just a tool, not a daemon.
or, we were explicitly told we don't have
the usual config sources.
thus it is not imperative that we find what we
were looking for...
*/
return;
} else {
fprintf( stderr, "%s error: ENABLE_PERSISTENT_CONFIG is TRUE, "
"but neither %s nor PERSISTENT_CONFIG_DIR is "
"specified in the configuration file\n",
myDistro->GetCap(), filename_parameter.Value() );
exit( 1 );
}
}
toplevel_persistent_config.sprintf( "%s%c.config.%s", tmp,
DIR_DELIM_CHAR,
get_mySubSystem()->getName() );
free(tmp);
}
| DoS Exec Code | 0 | init_dynamic_config()
{
static bool initialized = false;
if( initialized ) {
return;
}
enable_runtime = param_boolean( "ENABLE_RUNTIME_CONFIG", false );
enable_persistent = param_boolean( "ENABLE_PERSISTENT_CONFIG", false );
initialized = true;
if( !enable_persistent ) {
return;
}
char* tmp;
MyString filename_parameter;
filename_parameter.sprintf( "%s_CONFIG", get_mySubSystem()->getName() );
tmp = param( filename_parameter.Value() );
if( tmp ) {
toplevel_persistent_config = tmp;
free( tmp );
return;
}
tmp = param( "PERSISTENT_CONFIG_DIR" );
if( !tmp ) {
if ( get_mySubSystem()->isClient( ) || !have_config_source ) {
/*
we are just a tool, not a daemon.
or, we were explicitly told we don't have
the usual config sources.
thus it is not imperative that we find what we
were looking for...
*/
return;
} else {
fprintf( stderr, "%s error: ENABLE_PERSISTENT_CONFIG is TRUE, "
"but neither %s nor PERSISTENT_CONFIG_DIR is "
"specified in the configuration file\n",
myDistro->GetCap(), filename_parameter.Value() );
exit( 1 );
}
}
toplevel_persistent_config.sprintf( "%s%c.config.%s", tmp,
DIR_DELIM_CHAR,
get_mySubSystem()->getName() );
free(tmp);
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,228 | init_tilde()
{
if( tilde ) {
free( tilde );
tilde = NULL;
}
# if defined UNIX
struct passwd *pw;
if( (pw=getpwnam( myDistro->Get() )) ) {
tilde = strdup( pw->pw_dir );
}
# else
HKEY handle;
char regKey[1024];
snprintf( regKey, 1024, "Software\\%s", myDistro->GetCap() );
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey,
0, KEY_READ, &handle) == ERROR_SUCCESS ) {
char the_path[MAX_PATH];
DWORD valType;
DWORD valSize = MAX_PATH - 2;
the_path[0] = '\0';
if ( RegQueryValueEx(handle, "TILDE", 0,
&valType, (unsigned char *)the_path, &valSize) == ERROR_SUCCESS ) {
if ( valType == REG_SZ && the_path[0] ) {
tilde = strdup(the_path);
}
}
RegCloseKey(handle);
}
# endif
}
| DoS Exec Code | 0 | init_tilde()
{
if( tilde ) {
free( tilde );
tilde = NULL;
}
# if defined UNIX
struct passwd *pw;
if( (pw=getpwnam( myDistro->Get() )) ) {
tilde = strdup( pw->pw_dir );
}
# else
HKEY handle;
char regKey[1024];
snprintf( regKey, 1024, "Software\\%s", myDistro->GetCap() );
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey,
0, KEY_READ, &handle) == ERROR_SUCCESS ) {
char the_path[MAX_PATH];
DWORD valType;
DWORD valSize = MAX_PATH - 2;
the_path[0] = '\0';
if ( RegQueryValueEx(handle, "TILDE", 0,
&valType, (unsigned char *)the_path, &valSize) == ERROR_SUCCESS ) {
if ( valType == REG_SZ && the_path[0] ) {
tilde = strdup(the_path);
}
}
RegCloseKey(handle);
}
# endif
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,229 | void initialize() { admin = config = NULL; }
| DoS Exec Code | 0 | void initialize() { admin = config = NULL; }
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,230 | macro_expand( const char *str )
{
return( expand_macro(str, ConfigTab, TABLESIZE) );
}
| DoS Exec Code | 0 | macro_expand( const char *str )
{
return( expand_macro(str, ConfigTab, TABLESIZE) );
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,231 | param(const char* name)
{
/* The zero means return NULL on not found instead of EXCEPT */
return param_with_default_abort(name, 0);
}
| DoS Exec Code | 0 | param(const char* name)
{
/* The zero means return NULL on not found instead of EXCEPT */
return param_with_default_abort(name, 0);
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,232 | bool param(MyString &buf,char const *param_name,char const *default_value)
{
bool found = false;
char *param_value = param(param_name);
if( param_value ) {
buf = param_value;
found = true;
}
else if( default_value ) {
buf = default_value;
}
free( param_value );
return found;
}
| DoS Exec Code | 0 | bool param(MyString &buf,char const *param_name,char const *default_value)
{
bool found = false;
char *param_value = param(param_name);
if( param_value ) {
buf = param_value;
found = true;
}
else if( default_value ) {
buf = default_value;
}
free( param_value );
return found;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,233 | bool param(std::string &buf,char const *param_name,char const *default_value)
{
bool found = false;
char *param_value = param(param_name);
if( param_value ) {
buf = param_value;
found = true;
}
else if( default_value ) {
buf = default_value;
}
free( param_value );
return found;
}
| DoS Exec Code | 0 | bool param(std::string &buf,char const *param_name,char const *default_value)
{
bool found = false;
char *param_value = param(param_name);
if( param_value ) {
buf = param_value;
found = true;
}
else if( default_value ) {
buf = default_value;
}
free( param_value );
return found;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,234 | param_boolean( const char *name, bool default_value, bool do_log,
ClassAd *me, ClassAd *target,
bool use_param_table )
{
if(use_param_table) {
int tbl_default_valid;
bool tbl_default_value =
param_default_boolean( name, &tbl_default_valid );
if (tbl_default_valid) {
default_value = tbl_default_value;
}
}
bool result=false;
char *string;
char *endptr;
bool valid = true;
ASSERT( name );
string = param( name );
if (!string) {
if (do_log) {
dprintf( D_CONFIG, "%s is undefined, using default value of %s\n",
name, default_value ? "True" : "False" );
}
return default_value;
}
endptr = string;
if( strncasecmp(endptr,"true",4) == 0 ) {
endptr+=4;
result = true;
}
else if( strncasecmp(endptr,"1",1) == 0 ) {
endptr+=1;
result = true;
}
else if( strncasecmp(endptr,"false",5) == 0 ) {
endptr+=5;
result = false;
}
else if( strncasecmp(endptr,"0",1) == 0 ) {
endptr+=1;
result = false;
}
else {
valid = false;
}
while( isspace(*endptr) ) {
endptr++;
}
if( *endptr != '\0' ) {
valid = false;
}
if( !valid ) {
int int_value = default_value;
ClassAd rhs;
if( me ) {
rhs = *me;
}
if( rhs.AssignExpr( name, string ) &&
rhs.EvalBool(name,target,int_value) )
{
result = (int_value != 0);
valid = true;
}
}
if( !valid ) {
EXCEPT( "%s in the condor configuration is not a valid boolean (\"%s\")."
" Please set it to True or False (default is %s)",
name, string, default_value ? "True" : "False" );
}
free( string );
return result;
}
| DoS Exec Code | 0 | param_boolean( const char *name, bool default_value, bool do_log,
ClassAd *me, ClassAd *target,
bool use_param_table )
{
if(use_param_table) {
int tbl_default_valid;
bool tbl_default_value =
param_default_boolean( name, &tbl_default_valid );
if (tbl_default_valid) {
default_value = tbl_default_value;
}
}
bool result=false;
char *string;
char *endptr;
bool valid = true;
ASSERT( name );
string = param( name );
if (!string) {
if (do_log) {
dprintf( D_CONFIG, "%s is undefined, using default value of %s\n",
name, default_value ? "True" : "False" );
}
return default_value;
}
endptr = string;
if( strncasecmp(endptr,"true",4) == 0 ) {
endptr+=4;
result = true;
}
else if( strncasecmp(endptr,"1",1) == 0 ) {
endptr+=1;
result = true;
}
else if( strncasecmp(endptr,"false",5) == 0 ) {
endptr+=5;
result = false;
}
else if( strncasecmp(endptr,"0",1) == 0 ) {
endptr+=1;
result = false;
}
else {
valid = false;
}
while( isspace(*endptr) ) {
endptr++;
}
if( *endptr != '\0' ) {
valid = false;
}
if( !valid ) {
int int_value = default_value;
ClassAd rhs;
if( me ) {
rhs = *me;
}
if( rhs.AssignExpr( name, string ) &&
rhs.EvalBool(name,target,int_value) )
{
result = (int_value != 0);
valid = true;
}
}
if( !valid ) {
EXCEPT( "%s in the condor configuration is not a valid boolean (\"%s\")."
" Please set it to True or False (default is %s)",
name, string, default_value ? "True" : "False" );
}
free( string );
return result;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,235 | param_boolean_crufty( const char *name, bool default_value )
{
char *tmp = param(name);
if (tmp) {
char c = *tmp;
free(tmp);
if ('t' == c || 'T' == c) {
return true;
} else if ('f' == c || 'F' == c) {
return false;
} else {
return param_boolean(name, default_value);
}
} else {
return param_boolean(name, default_value);
}
}
| DoS Exec Code | 0 | param_boolean_crufty( const char *name, bool default_value )
{
char *tmp = param(name);
if (tmp) {
char c = *tmp;
free(tmp);
if ('t' == c || 'T' == c) {
return true;
} else if ('f' == c || 'F' == c) {
return false;
} else {
return param_boolean(name, default_value);
}
} else {
return param_boolean(name, default_value);
}
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,236 | param_boolean_int( const char *name, int default_value ) {
bool default_bool;
default_bool = default_value == 0 ? false : true;
return param_boolean(name, default_bool) ? 1 : 0;
}
| DoS Exec Code | 0 | param_boolean_int( const char *name, int default_value ) {
bool default_bool;
default_bool = default_value == 0 ? false : true;
return param_boolean(name, default_bool) ? 1 : 0;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,237 | bool param_defined(const char* name) {
char* v = param_without_default(name);
if (NULL == v) return false;
free(v);
return true;
}
| DoS Exec Code | 0 | bool param_defined(const char* name) {
char* v = param_without_default(name);
if (NULL == v) return false;
free(v);
return true;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,238 | param_double( const char *name, double default_value,
double min_value, double max_value,
ClassAd *me, ClassAd *target,
bool use_param_table )
{
if(use_param_table) {
int tbl_default_valid;
double tbl_default_value =
param_default_double( name, &tbl_default_valid );
param_range_double(name, &min_value, &max_value);
if (tbl_default_valid) {
default_value = tbl_default_value;
}
}
double result;
char *string;
char *endptr = NULL;
ASSERT( name );
string = param( name );
if( ! string ) {
dprintf( D_CONFIG, "%s is undefined, using default value of %f\n",
name, default_value );
return default_value;
}
result = strtod(string,&endptr);
ASSERT(endptr);
if( endptr != string ) {
while( isspace(*endptr) ) {
endptr++;
}
}
bool valid = (endptr != string && *endptr == '\0');
if( !valid ) {
ClassAd rhs;
float float_result;
if( me ) {
rhs = *me;
}
if( !rhs.AssignExpr( name, string ) ) {
EXCEPT("Invalid expression for %s (%s) "
"in condor configuration. Please set it to "
"a numeric expression in the range %lg to %lg "
"(default %lg).",
name,string,min_value,max_value,default_value);
}
if( !rhs.EvalFloat(name,target,float_result) ) {
EXCEPT("Invalid result (not a number) for %s (%s) "
"in condor configuration. Please set it to "
"a numeric expression in the range %lg to %lg "
"(default %lg).",
name,string,min_value,max_value,default_value);
}
result = float_result;
}
if( result < min_value ) {
EXCEPT( "%s in the condor configuration is too low (%s)."
" Please set it to a number in the range %lg to %lg"
" (default %lg).",
name, string, min_value, max_value, default_value );
}
else if( result > max_value ) {
EXCEPT( "%s in the condor configuration is too high (%s)."
" Please set it to a number in the range %lg to %lg"
" (default %lg).",
name, string, min_value, max_value, default_value );
}
free( string );
return result;
}
| DoS Exec Code | 0 | param_double( const char *name, double default_value,
double min_value, double max_value,
ClassAd *me, ClassAd *target,
bool use_param_table )
{
if(use_param_table) {
int tbl_default_valid;
double tbl_default_value =
param_default_double( name, &tbl_default_valid );
param_range_double(name, &min_value, &max_value);
if (tbl_default_valid) {
default_value = tbl_default_value;
}
}
double result;
char *string;
char *endptr = NULL;
ASSERT( name );
string = param( name );
if( ! string ) {
dprintf( D_CONFIG, "%s is undefined, using default value of %f\n",
name, default_value );
return default_value;
}
result = strtod(string,&endptr);
ASSERT(endptr);
if( endptr != string ) {
while( isspace(*endptr) ) {
endptr++;
}
}
bool valid = (endptr != string && *endptr == '\0');
if( !valid ) {
ClassAd rhs;
float float_result;
if( me ) {
rhs = *me;
}
if( !rhs.AssignExpr( name, string ) ) {
EXCEPT("Invalid expression for %s (%s) "
"in condor configuration. Please set it to "
"a numeric expression in the range %lg to %lg "
"(default %lg).",
name,string,min_value,max_value,default_value);
}
if( !rhs.EvalFloat(name,target,float_result) ) {
EXCEPT("Invalid result (not a number) for %s (%s) "
"in condor configuration. Please set it to "
"a numeric expression in the range %lg to %lg "
"(default %lg).",
name,string,min_value,max_value,default_value);
}
result = float_result;
}
if( result < min_value ) {
EXCEPT( "%s in the condor configuration is too low (%s)."
" Please set it to a number in the range %lg to %lg"
" (default %lg).",
name, string, min_value, max_value, default_value );
}
else if( result > max_value ) {
EXCEPT( "%s in the condor configuration is too high (%s)."
" Please set it to a number in the range %lg to %lg"
" (default %lg).",
name, string, min_value, max_value, default_value );
}
free( string );
return result;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,239 | param_integer( const char *name, int &value,
bool use_default, int default_value,
bool check_ranges, int min_value, int max_value,
ClassAd *me, ClassAd *target,
bool use_param_table )
{
if(use_param_table) {
int tbl_default_valid;
int tbl_default_value =
param_default_integer( name, &tbl_default_valid );
bool tbl_check_ranges =
(param_range_integer(name, &min_value, &max_value)==-1)
? false : true;
if (tbl_default_valid) {
use_default = true;
default_value = tbl_default_value;
}
if (tbl_check_ranges) {
check_ranges = true;
}
}
int result;
long long_result;
char *string;
char *endptr = NULL;
ASSERT( name );
string = param( name );
if( ! string ) {
dprintf( D_CONFIG, "%s is undefined, using default value of %d\n",
name, default_value );
if ( use_default ) {
value = default_value;
}
return false;
}
long_result = strtol(string,&endptr,10);
result = long_result;
ASSERT(endptr);
if( endptr != string ) {
while( isspace(*endptr) ) {
endptr++;
}
}
bool valid = (endptr != string && *endptr == '\0');
if( !valid ) {
ClassAd rhs;
if( me ) {
rhs = *me;
}
if( !rhs.AssignExpr( name, string ) ) {
EXCEPT("Invalid expression for %s (%s) "
"in condor configuration. Please set it to "
"an integer expression in the range %d to %d "
"(default %d).",
name,string,min_value,max_value,default_value);
}
if( !rhs.EvalInteger(name,target,result) ) {
EXCEPT("Invalid result (not an integer) for %s (%s) "
"in condor configuration. Please set it to "
"an integer expression in the range %d to %d "
"(default %d).",
name,string,min_value,max_value,default_value);
}
long_result = result;
}
if( (long)result != long_result ) {
EXCEPT( "%s in the condor configuration is out of bounds for"
" an integer (%s)."
" Please set it to an integer in the range %d to %d"
" (default %d).",
name, string, min_value, max_value, default_value );
}
else if ( check_ranges && ( result < min_value ) ) {
EXCEPT( "%s in the condor configuration is too low (%s)."
" Please set it to an integer in the range %d to %d"
" (default %d).",
name, string, min_value, max_value, default_value );
}
else if ( check_ranges && ( result > max_value ) ) {
EXCEPT( "%s in the condor configuration is too high (%s)."
" Please set it to an integer in the range %d to %d"
" (default %d).",
name, string, min_value, max_value, default_value );
}
free( string );
value = result;
return true;
}
| DoS Exec Code | 0 | param_integer( const char *name, int &value,
bool use_default, int default_value,
bool check_ranges, int min_value, int max_value,
ClassAd *me, ClassAd *target,
bool use_param_table )
{
if(use_param_table) {
int tbl_default_valid;
int tbl_default_value =
param_default_integer( name, &tbl_default_valid );
bool tbl_check_ranges =
(param_range_integer(name, &min_value, &max_value)==-1)
? false : true;
if (tbl_default_valid) {
use_default = true;
default_value = tbl_default_value;
}
if (tbl_check_ranges) {
check_ranges = true;
}
}
int result;
long long_result;
char *string;
char *endptr = NULL;
ASSERT( name );
string = param( name );
if( ! string ) {
dprintf( D_CONFIG, "%s is undefined, using default value of %d\n",
name, default_value );
if ( use_default ) {
value = default_value;
}
return false;
}
long_result = strtol(string,&endptr,10);
result = long_result;
ASSERT(endptr);
if( endptr != string ) {
while( isspace(*endptr) ) {
endptr++;
}
}
bool valid = (endptr != string && *endptr == '\0');
if( !valid ) {
ClassAd rhs;
if( me ) {
rhs = *me;
}
if( !rhs.AssignExpr( name, string ) ) {
EXCEPT("Invalid expression for %s (%s) "
"in condor configuration. Please set it to "
"an integer expression in the range %d to %d "
"(default %d).",
name,string,min_value,max_value,default_value);
}
if( !rhs.EvalInteger(name,target,result) ) {
EXCEPT("Invalid result (not an integer) for %s (%s) "
"in condor configuration. Please set it to "
"an integer expression in the range %d to %d "
"(default %d).",
name,string,min_value,max_value,default_value);
}
long_result = result;
}
if( (long)result != long_result ) {
EXCEPT( "%s in the condor configuration is out of bounds for"
" an integer (%s)."
" Please set it to an integer in the range %d to %d"
" (default %d).",
name, string, min_value, max_value, default_value );
}
else if ( check_ranges && ( result < min_value ) ) {
EXCEPT( "%s in the condor configuration is too low (%s)."
" Please set it to an integer in the range %d to %d"
" (default %d).",
name, string, min_value, max_value, default_value );
}
else if ( check_ranges && ( result > max_value ) ) {
EXCEPT( "%s in the condor configuration is too high (%s)."
" Please set it to an integer in the range %d to %d"
" (default %d).",
name, string, min_value, max_value, default_value );
}
free( string );
value = result;
return true;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,240 | param_integer( const char *name, int default_value,
int min_value, int max_value, bool use_param_table )
{
int result;
param_integer( name, result, true, default_value,
true, min_value, max_value, NULL, NULL, use_param_table );
return result;
}
| DoS Exec Code | 0 | param_integer( const char *name, int default_value,
int min_value, int max_value, bool use_param_table )
{
int result;
param_integer( name, result, true, default_value,
true, min_value, max_value, NULL, NULL, use_param_table );
return result;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,241 | int param_integer_c( const char *name, int default_value,
int min_value, int max_value, bool use_param_table )
{
return param_integer( name, default_value, min_value, max_value, use_param_table );
}
| DoS Exec Code | 0 | int param_integer_c( const char *name, int default_value,
int min_value, int max_value, bool use_param_table )
{
return param_integer( name, default_value, min_value, max_value, use_param_table );
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,242 | char* param_or_except(const char *attr)
{
char *tmp = NULL;
tmp = param(attr);
if (tmp == NULL || strlen(tmp) <= 0) {
EXCEPT("Please define config file entry to non-null value: %s", attr);
}
return tmp;
}
| DoS Exec Code | 0 | char* param_or_except(const char *attr)
{
char *tmp = NULL;
tmp = param(attr);
if (tmp == NULL || strlen(tmp) <= 0) {
EXCEPT("Please define config file entry to non-null value: %s", attr);
}
return tmp;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,243 | param_with_default_abort(const char *name, int abort)
{
char *val = NULL;
char *next_param_name = NULL;
MyString subsys = get_mySubSystem()->getName();
MyString local = get_mySubSystem()->getLocalName();
MyString subsys_local_name;
MyString local_name;
MyString subsys_name;
StringList sl;
if (local != "") {
subsys_local_name = (((subsys + ".") + local) + ".") + name;
sl.append(subsys_local_name.Value());
local_name = (local + ".") + name;
sl.append(local_name.Value());
}
subsys_name = (subsys + ".") + name;
sl.append(subsys_name.Value());
sl.append(name);
sl.rewind();
while(val == NULL && (next_param_name = sl.next())) {
val = lookup_macro(next_param_name, ConfigTab, TABLESIZE);
if (val != NULL && val[0] == '\0') {
return NULL;
}
if (val != NULL) {
break;
}
const char * def = param_default_string(next_param_name);
if (def != NULL) {
insert(next_param_name, def, ConfigTab, TABLESIZE);
if (extra_info != NULL) {
extra_info->AddInternalParam(next_param_name);
}
if (def[0] == '\0') {
return NULL;
}
val = const_cast<char*>(def); // TJ: this is naughty, but expand_macro will replace it soon.
}
}
if (val == NULL) {
if (abort) {
EXCEPT("Param name '%s' did not have a definition in any of the "
"usual namespaces or default table. Aborting since it MUST "
"be defined.\n", name);
}
return NULL;
}
val = expand_macro( val, ConfigTab, TABLESIZE, NULL, true );
if( val == NULL ) {
return NULL;
}
if ( val[0] == '\0' ) {
free( val );
return NULL;
}
return val;
}
| DoS Exec Code | 0 | param_with_default_abort(const char *name, int abort)
{
char *val = NULL;
char *next_param_name = NULL;
MyString subsys = get_mySubSystem()->getName();
MyString local = get_mySubSystem()->getLocalName();
MyString subsys_local_name;
MyString local_name;
MyString subsys_name;
StringList sl;
if (local != "") {
subsys_local_name = (((subsys + ".") + local) + ".") + name;
sl.append(subsys_local_name.Value());
local_name = (local + ".") + name;
sl.append(local_name.Value());
}
subsys_name = (subsys + ".") + name;
sl.append(subsys_name.Value());
sl.append(name);
sl.rewind();
while(val == NULL && (next_param_name = sl.next())) {
val = lookup_macro(next_param_name, ConfigTab, TABLESIZE);
if (val != NULL && val[0] == '\0') {
return NULL;
}
if (val != NULL) {
break;
}
const char * def = param_default_string(next_param_name);
if (def != NULL) {
insert(next_param_name, def, ConfigTab, TABLESIZE);
if (extra_info != NULL) {
extra_info->AddInternalParam(next_param_name);
}
if (def[0] == '\0') {
return NULL;
}
val = const_cast<char*>(def); // TJ: this is naughty, but expand_macro will replace it soon.
}
}
if (val == NULL) {
if (abort) {
EXCEPT("Param name '%s' did not have a definition in any of the "
"usual namespaces or default table. Aborting since it MUST "
"be defined.\n", name);
}
return NULL;
}
val = expand_macro( val, ConfigTab, TABLESIZE, NULL, true );
if( val == NULL ) {
return NULL;
}
if ( val[0] == '\0' ) {
free( val );
return NULL;
}
return val;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,244 | param_without_default( const char *name )
{
char *val = NULL;
char param_name[MAX_PARAM_LEN];
const char *local = get_mySubSystem()->getLocalName();
if ( (NULL == val) && local ) {
snprintf(param_name,MAX_PARAM_LEN,"%s.%s.%s",
get_mySubSystem()->getName(),
local,
name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( (NULL == val) && local ) {
snprintf(param_name,MAX_PARAM_LEN,"%s.%s",
local,
name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( NULL == val ) {
snprintf(param_name,MAX_PARAM_LEN,"%s.%s",
get_mySubSystem()->getName(),
name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( NULL == val ) {
snprintf(param_name,MAX_PARAM_LEN,"%s",name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( (NULL == val) || (*val=='\0') ) {
return NULL;
}
if( DebugFlags & D_CONFIG ) {
if( strlen(name) < strlen(param_name) ) {
param_name[strlen(param_name)-strlen(name)] = '\0';
dprintf( D_CONFIG, "Config '%s': using prefix '%s' ==> '%s'\n",
name, param_name, val );
}
else {
dprintf( D_CONFIG, "Config '%s': no prefix ==> '%s'\n", name, val );
}
}
val = expand_macro( val, ConfigTab, TABLESIZE );
if( val == NULL ) {
return NULL;
} else if ( val[0] == '\0' ) {
free( val );
return( NULL );
} else {
return val;
}
}
| DoS Exec Code | 0 | param_without_default( const char *name )
{
char *val = NULL;
char param_name[MAX_PARAM_LEN];
const char *local = get_mySubSystem()->getLocalName();
if ( (NULL == val) && local ) {
snprintf(param_name,MAX_PARAM_LEN,"%s.%s.%s",
get_mySubSystem()->getName(),
local,
name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( (NULL == val) && local ) {
snprintf(param_name,MAX_PARAM_LEN,"%s.%s",
local,
name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( NULL == val ) {
snprintf(param_name,MAX_PARAM_LEN,"%s.%s",
get_mySubSystem()->getName(),
name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( NULL == val ) {
snprintf(param_name,MAX_PARAM_LEN,"%s",name);
param_name[MAX_PARAM_LEN-1]='\0';
strlwr(param_name);
val = lookup_macro_lower( param_name, ConfigTab, TABLESIZE );
}
if ( (NULL == val) || (*val=='\0') ) {
return NULL;
}
if( DebugFlags & D_CONFIG ) {
if( strlen(name) < strlen(param_name) ) {
param_name[strlen(param_name)-strlen(name)] = '\0';
dprintf( D_CONFIG, "Config '%s': using prefix '%s' ==> '%s'\n",
name, param_name, val );
}
else {
dprintf( D_CONFIG, "Config '%s': no prefix ==> '%s'\n", name, val );
}
}
val = expand_macro( val, ConfigTab, TABLESIZE );
if( val == NULL ) {
return NULL;
} else if ( val[0] == '\0' ) {
free( val );
return( NULL );
} else {
return val;
}
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,245 | process_config_source( const char* file, const char* name,
const char* host, int required )
{
int rval;
if( access( file, R_OK ) != 0 && !is_piped_command(file)) {
if( !required) { return; }
if( !host ) {
fprintf( stderr, "ERROR: Can't read %s %s\n",
name, file );
exit( 1 );
}
} else {
rval = Read_config( file, ConfigTab, TABLESIZE, EXPAND_LAZY,
false, extra_info );
if( rval < 0 ) {
fprintf( stderr,
"Configuration Error Line %d while reading %s %s\n",
ConfigLineNo, name, file );
exit( 1 );
}
}
}
| DoS Exec Code | 0 | process_config_source( const char* file, const char* name,
const char* host, int required )
{
int rval;
if( access( file, R_OK ) != 0 && !is_piped_command(file)) {
if( !required) { return; }
if( !host ) {
fprintf( stderr, "ERROR: Can't read %s %s\n",
name, file );
exit( 1 );
}
} else {
rval = Read_config( file, ConfigTab, TABLESIZE, EXPAND_LAZY,
false, extra_info );
if( rval < 0 ) {
fprintf( stderr,
"Configuration Error Line %d while reading %s %s\n",
ConfigLineNo, name, file );
exit( 1 );
}
}
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,246 | process_directory( char* dirlist, char* host )
{
StringList locals;
Directory *files;
const char *file, *dirpath;
char **paths;
int local_required;
Regex excludeFilesRegex;
local_required = param_boolean_crufty("REQUIRE_LOCAL_CONFIG_FILE", true);
if(!dirlist) { return; }
locals.initializeFromString( dirlist );
locals.rewind();
get_exclude_regex(excludeFilesRegex);
while( (dirpath = locals.next()) ) {
paths = (char **)calloc(65536, sizeof(char *));
files = new Directory(dirpath);
int i = 0;
if(files == NULL) {
fprintf(stderr, "Cannot open %s\n", dirpath);
} else {
while( (file = files->Next()) && i < 65536) {
if(! files->IsDirectory() ) {
if(!excludeFilesRegex.isInitialized() ||
!excludeFilesRegex.match(file)) {
paths[i] = strdup(files->GetFullPath());
i++;
} else {
dprintf(D_FULLDEBUG|D_CONFIG,
"Ignoring config file "
"based on "
"LOCAL_CONFIG_DIR_EXCLUDE_REGEXP, "
"'%s'\n", files->GetFullPath());
}
}
}
delete files;
}
qsort(paths, i, sizeof(char *), compareFiles);
char **pathCopy = paths;
while(*pathCopy) {
process_config_source( *pathCopy, "config source", host,
local_required );
local_config_sources.append(*pathCopy);
free(*pathCopy);
pathCopy++;
}
free(paths);
}
}
| DoS Exec Code | 0 | process_directory( char* dirlist, char* host )
{
StringList locals;
Directory *files;
const char *file, *dirpath;
char **paths;
int local_required;
Regex excludeFilesRegex;
local_required = param_boolean_crufty("REQUIRE_LOCAL_CONFIG_FILE", true);
if(!dirlist) { return; }
locals.initializeFromString( dirlist );
locals.rewind();
get_exclude_regex(excludeFilesRegex);
while( (dirpath = locals.next()) ) {
paths = (char **)calloc(65536, sizeof(char *));
files = new Directory(dirpath);
int i = 0;
if(files == NULL) {
fprintf(stderr, "Cannot open %s\n", dirpath);
} else {
while( (file = files->Next()) && i < 65536) {
if(! files->IsDirectory() ) {
if(!excludeFilesRegex.isInitialized() ||
!excludeFilesRegex.match(file)) {
paths[i] = strdup(files->GetFullPath());
i++;
} else {
dprintf(D_FULLDEBUG|D_CONFIG,
"Ignoring config file "
"based on "
"LOCAL_CONFIG_DIR_EXCLUDE_REGEXP, "
"'%s'\n", files->GetFullPath());
}
}
}
delete files;
}
qsort(paths, i, sizeof(char *), compareFiles);
char **pathCopy = paths;
while(*pathCopy) {
process_config_source( *pathCopy, "config source", host,
local_required );
local_config_sources.append(*pathCopy);
free(*pathCopy);
pathCopy++;
}
free(paths);
}
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,247 | process_dynamic_configs()
{
int per_rval = 0;
int run_rval = 0;
init_dynamic_config();
if( enable_persistent ) {
per_rval = process_persistent_configs();
}
if( enable_runtime ) {
run_rval = process_runtime_configs();
}
if( per_rval < 0 || run_rval < 0 ) {
return -1;
}
if( per_rval || run_rval ) {
return 1;
}
return 0;
}
| DoS Exec Code | 0 | process_dynamic_configs()
{
int per_rval = 0;
int run_rval = 0;
init_dynamic_config();
if( enable_persistent ) {
per_rval = process_persistent_configs();
}
if( enable_runtime ) {
run_rval = process_runtime_configs();
}
if( per_rval < 0 || run_rval < 0 ) {
return -1;
}
if( per_rval || run_rval ) {
return 1;
}
return 0;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,248 | process_locals( const char* param_name, const char* host )
{
StringList sources_to_process, sources_done;
char *source, *sources_value;
int local_required;
local_required = param_boolean_crufty("REQUIRE_LOCAL_CONFIG_FILE", true);
sources_value = param( param_name );
if( sources_value ) {
if ( is_piped_command( sources_value ) ) {
sources_to_process.insert( sources_value );
} else {
sources_to_process.initializeFromString( sources_value );
}
sources_to_process.rewind();
while( (source = sources_to_process.next()) ) {
process_config_source( source, "config source", host,
local_required );
local_config_sources.append( source );
sources_done.append(source);
char* new_sources_value = param(param_name);
if(new_sources_value) {
if(strcmp(sources_value, new_sources_value) ) {
sources_to_process.clearAll();
if ( is_piped_command( new_sources_value ) ) {
sources_to_process.insert( new_sources_value );
} else {
sources_to_process.initializeFromString(new_sources_value);
}
sources_done.rewind();
while( (source = sources_done.next()) ) {
sources_to_process.remove(source);
}
sources_to_process.rewind();
free(sources_value);
sources_value = new_sources_value;
} else {
free(new_sources_value);
}
}
}
free(sources_value);
}
}
| DoS Exec Code | 0 | process_locals( const char* param_name, const char* host )
{
StringList sources_to_process, sources_done;
char *source, *sources_value;
int local_required;
local_required = param_boolean_crufty("REQUIRE_LOCAL_CONFIG_FILE", true);
sources_value = param( param_name );
if( sources_value ) {
if ( is_piped_command( sources_value ) ) {
sources_to_process.insert( sources_value );
} else {
sources_to_process.initializeFromString( sources_value );
}
sources_to_process.rewind();
while( (source = sources_to_process.next()) ) {
process_config_source( source, "config source", host,
local_required );
local_config_sources.append( source );
sources_done.append(source);
char* new_sources_value = param(param_name);
if(new_sources_value) {
if(strcmp(sources_value, new_sources_value) ) {
sources_to_process.clearAll();
if ( is_piped_command( new_sources_value ) ) {
sources_to_process.insert( new_sources_value );
} else {
sources_to_process.initializeFromString(new_sources_value);
}
sources_done.rewind();
while( (source = sources_done.next()) ) {
sources_to_process.remove(source);
}
sources_to_process.rewind();
free(sources_value);
sources_value = new_sources_value;
} else {
free(new_sources_value);
}
}
}
free(sources_value);
}
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,249 | process_persistent_configs()
{
char *tmp = NULL;
int rval;
bool processed = false;
if( access( toplevel_persistent_config.Value(), R_OK ) == 0 &&
PersistAdminList.number() == 0 )
{
processed = true;
rval = Read_config( toplevel_persistent_config.Value(), ConfigTab,
TABLESIZE, EXPAND_LAZY, true, extra_info );
if (rval < 0) {
dprintf( D_ALWAYS, "Configuration Error Line %d while reading "
"top-level persistent config source: %s\n",
ConfigLineNo, toplevel_persistent_config.Value() );
exit(1);
}
tmp = param ("RUNTIME_CONFIG_ADMIN");
if (tmp) {
PersistAdminList.initializeFromString(tmp);
free(tmp);
}
}
PersistAdminList.rewind();
while ((tmp = PersistAdminList.next())) {
processed = true;
MyString config_source;
config_source.sprintf( "%s.%s", toplevel_persistent_config.Value(),
tmp );
rval = Read_config( config_source.Value(), ConfigTab, TABLESIZE,
EXPAND_LAZY, true, extra_info );
if (rval < 0) {
dprintf( D_ALWAYS, "Configuration Error Line %d "
"while reading persistent config source: %s\n",
ConfigLineNo, config_source.Value() );
exit(1);
}
}
return (int)processed;
}
| DoS Exec Code | 0 | process_persistent_configs()
{
char *tmp = NULL;
int rval;
bool processed = false;
if( access( toplevel_persistent_config.Value(), R_OK ) == 0 &&
PersistAdminList.number() == 0 )
{
processed = true;
rval = Read_config( toplevel_persistent_config.Value(), ConfigTab,
TABLESIZE, EXPAND_LAZY, true, extra_info );
if (rval < 0) {
dprintf( D_ALWAYS, "Configuration Error Line %d while reading "
"top-level persistent config source: %s\n",
ConfigLineNo, toplevel_persistent_config.Value() );
exit(1);
}
tmp = param ("RUNTIME_CONFIG_ADMIN");
if (tmp) {
PersistAdminList.initializeFromString(tmp);
free(tmp);
}
}
PersistAdminList.rewind();
while ((tmp = PersistAdminList.next())) {
processed = true;
MyString config_source;
config_source.sprintf( "%s.%s", toplevel_persistent_config.Value(),
tmp );
rval = Read_config( config_source.Value(), ConfigTab, TABLESIZE,
EXPAND_LAZY, true, extra_info );
if (rval < 0) {
dprintf( D_ALWAYS, "Configuration Error Line %d "
"while reading persistent config source: %s\n",
ConfigLineNo, config_source.Value() );
exit(1);
}
}
return (int)processed;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,250 | reinsert_specials( char* host )
{
static unsigned int reinsert_pid = 0;
static unsigned int reinsert_ppid = 0;
static bool warned_no_user = false;
char buf[40];
if( tilde ) {
insert( "TILDE", tilde, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("TILDE");
}
if( host ) {
insert( "HOSTNAME", host, ConfigTab, TABLESIZE );
} else {
insert( "HOSTNAME", get_local_hostname().Value(), ConfigTab,
TABLESIZE );
}
insert( "FULL_HOSTNAME", get_local_fqdn().Value(), ConfigTab, TABLESIZE );
insert( "SUBSYSTEM", get_mySubSystem()->getName(), ConfigTab, TABLESIZE );
extra_info->AddInternalParam("HOSTNAME");
extra_info->AddInternalParam("FULL_HOSTNAME");
extra_info->AddInternalParam("SUBSYSTEM");
char *myusernm = my_username();
if( myusernm ) {
insert( "USERNAME", myusernm, ConfigTab, TABLESIZE );
free(myusernm);
myusernm = NULL;
extra_info->AddInternalParam("USERNAME");
} else {
if( ! warned_no_user ) {
dprintf( D_ALWAYS, "ERROR: can't find username of current user! "
"BEWARE: $(USERNAME) will be undefined\n" );
warned_no_user = true;
}
}
{
uid_t myruid;
gid_t myrgid;
#ifdef WIN32
myruid = 666;
myrgid = 666;
#else
myruid = getuid();
myrgid = getgid();
#endif
snprintf(buf,40,"%u",myruid);
insert( "REAL_UID", buf, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("REAL_UID");
snprintf(buf,40,"%u",myrgid);
insert( "REAL_GID", buf, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("REAL_GID");
}
if (!reinsert_pid) {
#ifdef WIN32
reinsert_pid = ::GetCurrentProcessId();
#else
reinsert_pid = getpid();
#endif
}
snprintf(buf,40,"%u",reinsert_pid);
insert( "PID", buf, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("PID");
if ( !reinsert_ppid ) {
#ifdef WIN32
CSysinfo system_hackery;
reinsert_ppid = system_hackery.GetParentPID(reinsert_pid);
#else
reinsert_ppid = getppid();
#endif
}
snprintf(buf,40,"%u",reinsert_ppid);
insert( "PPID", buf, ConfigTab, TABLESIZE );
insert( "IP_ADDRESS", my_ip_string(), ConfigTab, TABLESIZE );
extra_info->AddInternalParam("PPID");
extra_info->AddInternalParam("IP_ADDRESS");
}
| DoS Exec Code | 0 | reinsert_specials( char* host )
{
static unsigned int reinsert_pid = 0;
static unsigned int reinsert_ppid = 0;
static bool warned_no_user = false;
char buf[40];
if( tilde ) {
insert( "TILDE", tilde, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("TILDE");
}
if( host ) {
insert( "HOSTNAME", host, ConfigTab, TABLESIZE );
} else {
insert( "HOSTNAME", get_local_hostname().Value(), ConfigTab,
TABLESIZE );
}
insert( "FULL_HOSTNAME", get_local_fqdn().Value(), ConfigTab, TABLESIZE );
insert( "SUBSYSTEM", get_mySubSystem()->getName(), ConfigTab, TABLESIZE );
extra_info->AddInternalParam("HOSTNAME");
extra_info->AddInternalParam("FULL_HOSTNAME");
extra_info->AddInternalParam("SUBSYSTEM");
char *myusernm = my_username();
if( myusernm ) {
insert( "USERNAME", myusernm, ConfigTab, TABLESIZE );
free(myusernm);
myusernm = NULL;
extra_info->AddInternalParam("USERNAME");
} else {
if( ! warned_no_user ) {
dprintf( D_ALWAYS, "ERROR: can't find username of current user! "
"BEWARE: $(USERNAME) will be undefined\n" );
warned_no_user = true;
}
}
{
uid_t myruid;
gid_t myrgid;
#ifdef WIN32
myruid = 666;
myrgid = 666;
#else
myruid = getuid();
myrgid = getgid();
#endif
snprintf(buf,40,"%u",myruid);
insert( "REAL_UID", buf, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("REAL_UID");
snprintf(buf,40,"%u",myrgid);
insert( "REAL_GID", buf, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("REAL_GID");
}
if (!reinsert_pid) {
#ifdef WIN32
reinsert_pid = ::GetCurrentProcessId();
#else
reinsert_pid = getpid();
#endif
}
snprintf(buf,40,"%u",reinsert_pid);
insert( "PID", buf, ConfigTab, TABLESIZE );
extra_info->AddInternalParam("PID");
if ( !reinsert_ppid ) {
#ifdef WIN32
CSysinfo system_hackery;
reinsert_ppid = system_hackery.GetParentPID(reinsert_pid);
#else
reinsert_ppid = getppid();
#endif
}
snprintf(buf,40,"%u",reinsert_ppid);
insert( "PPID", buf, ConfigTab, TABLESIZE );
insert( "IP_ADDRESS", my_ip_string(), ConfigTab, TABLESIZE );
extra_info->AddInternalParam("PPID");
extra_info->AddInternalParam("IP_ADDRESS");
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,251 | set_persistent_config(char *admin, char *config)
{
int fd, rval;
char *tmp;
MyString filename;
MyString tmp_filename;
priv_state priv;
if (!admin || !admin[0] || !enable_persistent) {
if (!enable_persistent) {
dprintf( D_ALWAYS, "set_persistent_config(): "
"ENABLE_PERSISTENT_CONFIG is false. "
"Not setting persistent config file param: "
"Name = %s, Value = %s\n",
admin?admin:"(null pointer)",
config?config:"(null pointer)");
}
if (admin) { free(admin); }
if (config) { free(config); }
return -1;
}
init_dynamic_config();
if( ! toplevel_persistent_config.Length() ) {
EXCEPT( "Impossible: programmer error: toplevel_persistent_config "
"is 0-length, but we already initialized, enable_persistent "
"is TRUE, and set_persistent_config() has been called" );
}
priv = set_root_priv();
if (config && config[0]) { // (re-)set config
filename.sprintf( "%s.%s", toplevel_persistent_config.Value(), admin );
tmp_filename.sprintf( "%s.tmp", filename.Value() );
do {
unlink( tmp_filename.Value() );
fd = safe_open_wrapper_follow( tmp_filename.Value(), O_WRONLY|O_CREAT|O_EXCL, 0644 );
} while (fd == -1 && errno == EEXIST);
if( fd < 0 ) {
dprintf( D_ALWAYS, "safe_open_wrapper(%s) returned %d '%s' (errno %d) in "
"set_persistent_config()\n", tmp_filename.Value(),
fd, strerror(errno), errno );
ABORT;
}
if (write(fd, config, strlen(config)) != (ssize_t)strlen(config)) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
if (close(fd) < 0) {
dprintf( D_ALWAYS, "close() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
if (rotate_file(tmp_filename.Value(), filename.Value()) < 0) {
dprintf( D_ALWAYS, "rotate_file(%s,%s) failed with '%s' "
"(errno %d) in set_persistent_config()\n",
tmp_filename.Value(), filename.Value(),
strerror(errno), errno );
ABORT;
}
if (!PersistAdminList.contains(admin)) {
PersistAdminList.append(admin);
} else {
free(admin);
free(config);
set_priv(priv);
return 0; // if no update is required, then we are done
}
} else { // clear config
PersistAdminList.remove(admin);
if (config) {
free(config);
config = NULL;
}
}
tmp_filename.sprintf( "%s.tmp", toplevel_persistent_config.Value() );
do {
unlink( tmp_filename.Value() );
fd = safe_open_wrapper_follow( tmp_filename.Value(), O_WRONLY|O_CREAT|O_EXCL, 0644 );
} while (fd == -1 && errno == EEXIST);
if( fd < 0 ) {
dprintf( D_ALWAYS, "safe_open_wrapper(%s) returned %d '%s' (errno %d) in "
"set_persistent_config()\n", tmp_filename.Value(),
fd, strerror(errno), errno );
ABORT;
}
const char param[] = "RUNTIME_CONFIG_ADMIN = ";
if (write(fd, param, strlen(param)) != (ssize_t)strlen(param)) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
PersistAdminList.rewind();
bool first_time = true;
while( (tmp = PersistAdminList.next()) ) {
if (!first_time) {
if (write(fd, ", ", 2) != 2) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
} else {
first_time = false;
}
if (write(fd, tmp, strlen(tmp)) != (ssize_t)strlen(tmp)) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
}
if (write(fd, "\n", 1) != 1) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
if (close(fd) < 0) {
dprintf( D_ALWAYS, "close() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
rval = rotate_file( tmp_filename.Value(),
toplevel_persistent_config.Value() );
if (rval < 0) {
dprintf( D_ALWAYS, "rotate_file(%s,%s) failed with '%s' (errno %d) "
"in set_persistent_config()\n", tmp_filename.Value(),
filename.Value(), strerror(errno), errno );
ABORT;
}
if (!config || !config[0]) {
filename.sprintf( "%s.%s", toplevel_persistent_config.Value(), admin );
unlink( filename.Value() );
if (PersistAdminList.number() == 0) {
unlink( toplevel_persistent_config.Value() );
}
}
set_priv( priv );
free( admin );
if (config) { free( config ); }
return 0;
}
| DoS Exec Code | 0 | set_persistent_config(char *admin, char *config)
{
int fd, rval;
char *tmp;
MyString filename;
MyString tmp_filename;
priv_state priv;
if (!admin || !admin[0] || !enable_persistent) {
if (!enable_persistent) {
dprintf( D_ALWAYS, "set_persistent_config(): "
"ENABLE_PERSISTENT_CONFIG is false. "
"Not setting persistent config file param: "
"Name = %s, Value = %s\n",
admin?admin:"(null pointer)",
config?config:"(null pointer)");
}
if (admin) { free(admin); }
if (config) { free(config); }
return -1;
}
init_dynamic_config();
if( ! toplevel_persistent_config.Length() ) {
EXCEPT( "Impossible: programmer error: toplevel_persistent_config "
"is 0-length, but we already initialized, enable_persistent "
"is TRUE, and set_persistent_config() has been called" );
}
priv = set_root_priv();
if (config && config[0]) { // (re-)set config
filename.sprintf( "%s.%s", toplevel_persistent_config.Value(), admin );
tmp_filename.sprintf( "%s.tmp", filename.Value() );
do {
unlink( tmp_filename.Value() );
fd = safe_open_wrapper_follow( tmp_filename.Value(), O_WRONLY|O_CREAT|O_EXCL, 0644 );
} while (fd == -1 && errno == EEXIST);
if( fd < 0 ) {
dprintf( D_ALWAYS, "safe_open_wrapper(%s) returned %d '%s' (errno %d) in "
"set_persistent_config()\n", tmp_filename.Value(),
fd, strerror(errno), errno );
ABORT;
}
if (write(fd, config, strlen(config)) != (ssize_t)strlen(config)) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
if (close(fd) < 0) {
dprintf( D_ALWAYS, "close() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
if (rotate_file(tmp_filename.Value(), filename.Value()) < 0) {
dprintf( D_ALWAYS, "rotate_file(%s,%s) failed with '%s' "
"(errno %d) in set_persistent_config()\n",
tmp_filename.Value(), filename.Value(),
strerror(errno), errno );
ABORT;
}
if (!PersistAdminList.contains(admin)) {
PersistAdminList.append(admin);
} else {
free(admin);
free(config);
set_priv(priv);
return 0; // if no update is required, then we are done
}
} else { // clear config
PersistAdminList.remove(admin);
if (config) {
free(config);
config = NULL;
}
}
tmp_filename.sprintf( "%s.tmp", toplevel_persistent_config.Value() );
do {
unlink( tmp_filename.Value() );
fd = safe_open_wrapper_follow( tmp_filename.Value(), O_WRONLY|O_CREAT|O_EXCL, 0644 );
} while (fd == -1 && errno == EEXIST);
if( fd < 0 ) {
dprintf( D_ALWAYS, "safe_open_wrapper(%s) returned %d '%s' (errno %d) in "
"set_persistent_config()\n", tmp_filename.Value(),
fd, strerror(errno), errno );
ABORT;
}
const char param[] = "RUNTIME_CONFIG_ADMIN = ";
if (write(fd, param, strlen(param)) != (ssize_t)strlen(param)) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
PersistAdminList.rewind();
bool first_time = true;
while( (tmp = PersistAdminList.next()) ) {
if (!first_time) {
if (write(fd, ", ", 2) != 2) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
} else {
first_time = false;
}
if (write(fd, tmp, strlen(tmp)) != (ssize_t)strlen(tmp)) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
}
if (write(fd, "\n", 1) != 1) {
dprintf( D_ALWAYS, "write() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
if (close(fd) < 0) {
dprintf( D_ALWAYS, "close() failed with '%s' (errno %d) in "
"set_persistent_config()\n", strerror(errno), errno );
ABORT;
}
rval = rotate_file( tmp_filename.Value(),
toplevel_persistent_config.Value() );
if (rval < 0) {
dprintf( D_ALWAYS, "rotate_file(%s,%s) failed with '%s' (errno %d) "
"in set_persistent_config()\n", tmp_filename.Value(),
filename.Value(), strerror(errno), errno );
ABORT;
}
if (!config || !config[0]) {
filename.sprintf( "%s.%s", toplevel_persistent_config.Value(), admin );
unlink( filename.Value() );
if (PersistAdminList.number() == 0) {
unlink( toplevel_persistent_config.Value() );
}
}
set_priv( priv );
free( admin );
if (config) { free( config ); }
return 0;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,252 | set_runtime_config(char *admin, char *config)
{
int i;
if (!admin || !admin[0] || !enable_runtime) {
if (admin) { free(admin); }
if (config) { free(config); }
return -1;
}
if (config && config[0]) {
for (i=0; i <= rArray.getlast(); i++) {
if (strcmp(rArray[i].admin, admin) == MATCH) {
free(admin);
free(rArray[i].config);
rArray[i].config = config;
return 0;
}
}
rArray[i].admin = admin;
rArray[i].config = config;
} else {
for (i=0; i <= rArray.getlast(); i++) {
if (strcmp(rArray[i].admin, admin) == MATCH) {
free(admin);
if (config) free(config);
free(rArray[i].admin);
free(rArray[i].config);
rArray[i] = rArray[rArray.getlast()];
rArray[rArray.getlast()].initialize();
rArray.truncate(rArray.getlast()-1);
return 0;
}
}
}
return 0;
}
| DoS Exec Code | 0 | set_runtime_config(char *admin, char *config)
{
int i;
if (!admin || !admin[0] || !enable_runtime) {
if (admin) { free(admin); }
if (config) { free(config); }
return -1;
}
if (config && config[0]) {
for (i=0; i <= rArray.getlast(); i++) {
if (strcmp(rArray[i].admin, admin) == MATCH) {
free(admin);
free(rArray[i].config);
rArray[i].config = config;
return 0;
}
}
rArray[i].admin = admin;
rArray[i].config = config;
} else {
for (i=0; i <= rArray.getlast(); i++) {
if (strcmp(rArray[i].admin, admin) == MATCH) {
free(admin);
if (config) free(config);
free(rArray[i].admin);
free(rArray[i].config);
rArray[i] = rArray[rArray.getlast()];
rArray[rArray.getlast()].initialize();
rArray.truncate(rArray.getlast()-1);
return 0;
}
}
}
return 0;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,253 | write_config_file(const char* pathname) {
int config_fd = creat(pathname, O_WRONLY);
if(config_fd == -1) {
dprintf(D_ALWAYS, "Failed to create configuration file.\n");
return -1;
}
iterate_params(&write_config_variable, &config_fd);
if(close(config_fd) == -1) {
dprintf(D_ALWAYS, "Error closing new configuration file.\n");
return -1;
}
return 0;
}
| DoS Exec Code | 0 | write_config_file(const char* pathname) {
int config_fd = creat(pathname, O_WRONLY);
if(config_fd == -1) {
dprintf(D_ALWAYS, "Failed to create configuration file.\n");
return -1;
}
iterate_params(&write_config_variable, &config_fd);
if(close(config_fd) == -1) {
dprintf(D_ALWAYS, "Error closing new configuration file.\n");
return -1;
}
return 0;
}
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,254 | ~RuntimeConfigItem() { if (admin) free(admin); if (config) free(config); }
| DoS Exec Code | 0 | ~RuntimeConfigItem() { if (admin) free(admin); if (config) free(config); }
| @@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) {
if(ignore_invalid_entry) {
dprintf(D_ALWAYS, "%s", output.Value());
} else {
- EXCEPT(output.Value());
+ EXCEPT("%s", output.Value());
}
}
} | CWE-134 | null | null |
13,255 | CronTab::CronTab()
{
this->lastRunTime = CRONTAB_INVALID;
this->valid = false;
}
| DoS Exec Code | 0 | CronTab::CronTab()
{
this->lastRunTime = CRONTAB_INVALID;
this->valid = false;
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,256 | CronTab::CronTab( int minutes,
int hours,
int days_of_month,
int months,
int days_of_week ) {
if ( minutes == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_MINUTES_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_MINUTES_IDX] = new MyString( minutes );
}
if ( hours == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_HOURS_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_HOURS_IDX] = new MyString( hours );
}
if ( days_of_month == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_DOM_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_DOM_IDX] = new MyString( days_of_month );
}
if ( months == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_MONTHS_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_MONTHS_IDX] = new MyString( months );
}
if ( days_of_week == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_DOW_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_DOW_IDX] = new MyString( days_of_week );
}
this->init();
}
| DoS Exec Code | 0 | CronTab::CronTab( int minutes,
int hours,
int days_of_month,
int months,
int days_of_week ) {
if ( minutes == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_MINUTES_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_MINUTES_IDX] = new MyString( minutes );
}
if ( hours == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_HOURS_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_HOURS_IDX] = new MyString( hours );
}
if ( days_of_month == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_DOM_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_DOM_IDX] = new MyString( days_of_month );
}
if ( months == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_MONTHS_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_MONTHS_IDX] = new MyString( months );
}
if ( days_of_week == CRONTAB_CRONOS_STAR ) {
this->parameters[CRONTAB_DOW_IDX] = new MyString( CRONTAB_WILDCARD );
} else {
this->parameters[CRONTAB_DOW_IDX] = new MyString( days_of_week );
}
this->init();
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,257 | CronTab::CronTab( const char* minutes,
const char* hours,
const char* days_of_month,
const char* months,
const char* days_of_week ) {
this->parameters[CRONTAB_MINUTES_IDX] = new MyString( minutes );
this->parameters[CRONTAB_HOURS_IDX] = new MyString( hours );
this->parameters[CRONTAB_DOM_IDX] = new MyString( days_of_month );
this->parameters[CRONTAB_MONTHS_IDX] = new MyString( months );
this->parameters[CRONTAB_DOW_IDX] = new MyString( days_of_week );
this->init();
}
| DoS Exec Code | 0 | CronTab::CronTab( const char* minutes,
const char* hours,
const char* days_of_month,
const char* months,
const char* days_of_week ) {
this->parameters[CRONTAB_MINUTES_IDX] = new MyString( minutes );
this->parameters[CRONTAB_HOURS_IDX] = new MyString( hours );
this->parameters[CRONTAB_DOM_IDX] = new MyString( days_of_month );
this->parameters[CRONTAB_MONTHS_IDX] = new MyString( months );
this->parameters[CRONTAB_DOW_IDX] = new MyString( days_of_week );
this->init();
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,258 | CronTab::contains( ExtArray<int> &list, const int &elt )
{
bool ret = false;
int ctr;
for ( ctr = 0; ctr <= list.getlast(); ctr++ ) {
if ( elt == list[ctr] ) {
ret = true;
break;
}
} // FOR
return ( ret );
}
| DoS Exec Code | 0 | CronTab::contains( ExtArray<int> &list, const int &elt )
{
bool ret = false;
int ctr;
for ( ctr = 0; ctr <= list.getlast(); ctr++ ) {
if ( elt == list[ctr] ) {
ret = true;
break;
}
} // FOR
return ( ret );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,259 | CronTab::getError() {
return ( this->errorLog );
}
| DoS Exec Code | 0 | CronTab::getError() {
return ( this->errorLog );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,260 | CronTab::init() {
initRegexObject();
this->lastRunTime = CRONTAB_INVALID;
this->valid = false;
int mins[] = { CRONTAB_MINUTE_MIN,
CRONTAB_HOUR_MIN,
CRONTAB_DAY_OF_MONTH_MIN,
CRONTAB_MONTH_MIN,
CRONTAB_DAY_OF_WEEK_MIN
};
int maxs[] = { CRONTAB_MINUTE_MAX,
CRONTAB_HOUR_MAX,
CRONTAB_DAY_OF_MONTH_MAX,
CRONTAB_MONTH_MAX,
CRONTAB_DAY_OF_WEEK_MAX
};
bool failed = false;
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
this->ranges[ctr] = new ExtArray<int>();
if ( !this->expandParameter( ctr, mins[ctr], maxs[ctr] )) {
failed = true;
}
} // FOR
if ( !failed ) {
this->valid = true;
}
return;
}
| DoS Exec Code | 0 | CronTab::init() {
initRegexObject();
this->lastRunTime = CRONTAB_INVALID;
this->valid = false;
int mins[] = { CRONTAB_MINUTE_MIN,
CRONTAB_HOUR_MIN,
CRONTAB_DAY_OF_MONTH_MIN,
CRONTAB_MONTH_MIN,
CRONTAB_DAY_OF_WEEK_MIN
};
int maxs[] = { CRONTAB_MINUTE_MAX,
CRONTAB_HOUR_MAX,
CRONTAB_DAY_OF_MONTH_MAX,
CRONTAB_MONTH_MAX,
CRONTAB_DAY_OF_WEEK_MAX
};
bool failed = false;
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
this->ranges[ctr] = new ExtArray<int>();
if ( !this->expandParameter( ctr, mins[ctr], maxs[ctr] )) {
failed = true;
}
} // FOR
if ( !failed ) {
this->valid = true;
}
return;
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,261 | CronTab::matchFields( int *curTime, int *match, int attribute_idx, bool useFirst )
{
bool nextUseFirst = useFirst;
match[attribute_idx] = -1;
ExtArray<int> *curRange = NULL;
if ( attribute_idx == CRONTAB_DOM_IDX ) {
if (this->ranges[attribute_idx]->length()==CRONTAB_DAY_OF_MONTH_MAX){
if ((this->ranges[CRONTAB_DOW_IDX]->length()==CRONTAB_DAY_OF_WEEK_MAX)||
(this->ranges[CRONTAB_DOW_IDX]->length()==0)){
curRange = new ExtArray<int>( *this->ranges[attribute_idx] );
} else {
curRange = new ExtArray<int>( CRONTAB_DAY_OF_MONTH_MAX );
}
}else{
curRange = new ExtArray<int>( *this->ranges[attribute_idx] );
}
int firstDay = dayOfWeek( match[CRONTAB_MONTHS_IDX],
1,
match[CRONTAB_YEARS_IDX] );
int ctr, cnt;
for ( ctr = 0, cnt = this->ranges[CRONTAB_DOW_IDX]->getlast();
ctr <= cnt;
ctr++ ) {
int day = (this->ranges[CRONTAB_DOW_IDX]->getElementAt(ctr) - firstDay) + 1;
while ( day <= CRONTAB_DAY_OF_MONTH_MAX ) {
if (curRange && day > 0 && !this->contains( *curRange, day ) ) {
curRange->add( day );
}
day += 7;
} // WHILE
} // FOR
this->sort( *curRange );
} else {
curRange = this->ranges[attribute_idx];
}
bool ret = false;
int range_idx, cnt;
for ( range_idx = 0, cnt = curRange->getlast();
range_idx <= cnt;
range_idx++ ) {
int value = curRange->getElementAt( range_idx );
if ( useFirst || value >= curTime[attribute_idx] ) {
if ( value > curTime[attribute_idx] ) nextUseFirst = true;
if ( attribute_idx == CRONTAB_DOM_IDX ) {
int maxDOM = daysInMonth( match[CRONTAB_MONTHS_IDX],
match[CRONTAB_YEARS_IDX] );
if ( value > maxDOM ) {
continue;
}
}
match[attribute_idx] = value;
if ( attribute_idx == CRONTAB_MINUTES_IDX ) {
ret = true;
break;
} else {
ret = this->matchFields( curTime, match, attribute_idx - 1, nextUseFirst );
nextUseFirst = true;
if ( ret ) break;
}
}
} // FOR
if ( !ret && attribute_idx == CRONTAB_MONTHS_IDX ) {
match[CRONTAB_YEARS_IDX]++;
ret = this->matchFields( curTime, match, attribute_idx, true );
}
if ( attribute_idx == CRONTAB_DOM_IDX && curRange ) delete curRange;
return ( ret );
}
| DoS Exec Code | 0 | CronTab::matchFields( int *curTime, int *match, int attribute_idx, bool useFirst )
{
bool nextUseFirst = useFirst;
match[attribute_idx] = -1;
ExtArray<int> *curRange = NULL;
if ( attribute_idx == CRONTAB_DOM_IDX ) {
if (this->ranges[attribute_idx]->length()==CRONTAB_DAY_OF_MONTH_MAX){
if ((this->ranges[CRONTAB_DOW_IDX]->length()==CRONTAB_DAY_OF_WEEK_MAX)||
(this->ranges[CRONTAB_DOW_IDX]->length()==0)){
curRange = new ExtArray<int>( *this->ranges[attribute_idx] );
} else {
curRange = new ExtArray<int>( CRONTAB_DAY_OF_MONTH_MAX );
}
}else{
curRange = new ExtArray<int>( *this->ranges[attribute_idx] );
}
int firstDay = dayOfWeek( match[CRONTAB_MONTHS_IDX],
1,
match[CRONTAB_YEARS_IDX] );
int ctr, cnt;
for ( ctr = 0, cnt = this->ranges[CRONTAB_DOW_IDX]->getlast();
ctr <= cnt;
ctr++ ) {
int day = (this->ranges[CRONTAB_DOW_IDX]->getElementAt(ctr) - firstDay) + 1;
while ( day <= CRONTAB_DAY_OF_MONTH_MAX ) {
if (curRange && day > 0 && !this->contains( *curRange, day ) ) {
curRange->add( day );
}
day += 7;
} // WHILE
} // FOR
this->sort( *curRange );
} else {
curRange = this->ranges[attribute_idx];
}
bool ret = false;
int range_idx, cnt;
for ( range_idx = 0, cnt = curRange->getlast();
range_idx <= cnt;
range_idx++ ) {
int value = curRange->getElementAt( range_idx );
if ( useFirst || value >= curTime[attribute_idx] ) {
if ( value > curTime[attribute_idx] ) nextUseFirst = true;
if ( attribute_idx == CRONTAB_DOM_IDX ) {
int maxDOM = daysInMonth( match[CRONTAB_MONTHS_IDX],
match[CRONTAB_YEARS_IDX] );
if ( value > maxDOM ) {
continue;
}
}
match[attribute_idx] = value;
if ( attribute_idx == CRONTAB_MINUTES_IDX ) {
ret = true;
break;
} else {
ret = this->matchFields( curTime, match, attribute_idx - 1, nextUseFirst );
nextUseFirst = true;
if ( ret ) break;
}
}
} // FOR
if ( !ret && attribute_idx == CRONTAB_MONTHS_IDX ) {
match[CRONTAB_YEARS_IDX]++;
ret = this->matchFields( curTime, match, attribute_idx, true );
}
if ( attribute_idx == CRONTAB_DOM_IDX && curRange ) delete curRange;
return ( ret );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,262 | CronTab::needsCronTab( ClassAd *ad ) {
bool ret = false;
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
if ( ad->LookupExpr( CronTab::attributes[ctr] ) ) {
ret = true;
break;
}
} // FOR
return ( ret );
}
| DoS Exec Code | 0 | CronTab::needsCronTab( ClassAd *ad ) {
bool ret = false;
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
if ( ad->LookupExpr( CronTab::attributes[ctr] ) ) {
ret = true;
break;
}
} // FOR
return ( ret );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,263 | CronTab::nextRunTime( ) {
return ( this->nextRunTime( (long)time( NULL ) ) );
}
| DoS Exec Code | 0 | CronTab::nextRunTime( ) {
return ( this->nextRunTime( (long)time( NULL ) ) );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,264 | CronTab::nextRunTime( long timestamp ) {
long runtime = CRONTAB_INVALID;
struct tm *tm;
if ( ! this->valid ) {
this->lastRunTime = CRONTAB_INVALID;
return ( this->lastRunTime );
}
timestamp += ( 60 - ( timestamp % 60 ) );
const time_t _timestamp = (time_t)timestamp;
tm = localtime( &_timestamp );
int fields[CRONTAB_FIELDS];
fields[CRONTAB_MINUTES_IDX] = tm->tm_min;
fields[CRONTAB_HOURS_IDX] = tm->tm_hour;
fields[CRONTAB_DOM_IDX] = tm->tm_mday;
fields[CRONTAB_MONTHS_IDX] = tm->tm_mon + 1;
fields[CRONTAB_DOW_IDX] = tm->tm_wday;
int match[CRONTAB_FIELDS + 1];
match[CRONTAB_YEARS_IDX] = tm->tm_year + 1900;
match[CRONTAB_DOW_IDX] = -1;
if ( this->matchFields( fields, match, CRONTAB_FIELDS - 2 ) ) {
struct tm matchTime;
matchTime.tm_sec = 0;
matchTime.tm_min = match[CRONTAB_MINUTES_IDX];
matchTime.tm_hour = match[CRONTAB_HOURS_IDX];
matchTime.tm_mday = match[CRONTAB_DOM_IDX];
matchTime.tm_mon = match[CRONTAB_MONTHS_IDX] - 1;
matchTime.tm_year = match[CRONTAB_YEARS_IDX] - 1900;
matchTime.tm_isdst = -1; // auto-calculate whether daylight savings time applies
runtime = (long)mktime( &matchTime );
if ( runtime < timestamp ) {
EXCEPT( "CronTab: Generated a runtime that is in the past (%d < %d)"
, (int)runtime, (int)timestamp );
}
} else {
EXCEPT( "CronTab: Failed to find a match for timestamp %d",
(int)timestamp );
}
this->lastRunTime = runtime;
return ( runtime );
}
| DoS Exec Code | 0 | CronTab::nextRunTime( long timestamp ) {
long runtime = CRONTAB_INVALID;
struct tm *tm;
if ( ! this->valid ) {
this->lastRunTime = CRONTAB_INVALID;
return ( this->lastRunTime );
}
timestamp += ( 60 - ( timestamp % 60 ) );
const time_t _timestamp = (time_t)timestamp;
tm = localtime( &_timestamp );
int fields[CRONTAB_FIELDS];
fields[CRONTAB_MINUTES_IDX] = tm->tm_min;
fields[CRONTAB_HOURS_IDX] = tm->tm_hour;
fields[CRONTAB_DOM_IDX] = tm->tm_mday;
fields[CRONTAB_MONTHS_IDX] = tm->tm_mon + 1;
fields[CRONTAB_DOW_IDX] = tm->tm_wday;
int match[CRONTAB_FIELDS + 1];
match[CRONTAB_YEARS_IDX] = tm->tm_year + 1900;
match[CRONTAB_DOW_IDX] = -1;
if ( this->matchFields( fields, match, CRONTAB_FIELDS - 2 ) ) {
struct tm matchTime;
matchTime.tm_sec = 0;
matchTime.tm_min = match[CRONTAB_MINUTES_IDX];
matchTime.tm_hour = match[CRONTAB_HOURS_IDX];
matchTime.tm_mday = match[CRONTAB_DOM_IDX];
matchTime.tm_mon = match[CRONTAB_MONTHS_IDX] - 1;
matchTime.tm_year = match[CRONTAB_YEARS_IDX] - 1900;
matchTime.tm_isdst = -1; // auto-calculate whether daylight savings time applies
runtime = (long)mktime( &matchTime );
if ( runtime < timestamp ) {
EXCEPT( "CronTab: Generated a runtime that is in the past (%d < %d)"
, (int)runtime, (int)timestamp );
}
} else {
EXCEPT( "CronTab: Failed to find a match for timestamp %d",
(int)timestamp );
}
this->lastRunTime = runtime;
return ( runtime );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,265 | CronTab::validate( ClassAd *ad, MyString &error ) {
bool ret = true;
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
MyString buffer;
if ( ad->LookupString( CronTab::attributes[ctr], buffer ) ) {
MyString curError;
if ( !CronTab::validateParameter( ctr, buffer.Value(), curError ) ) {
ret = false;
error += curError;
}
}
} // FOR
return ( ret );
}
| DoS Exec Code | 0 | CronTab::validate( ClassAd *ad, MyString &error ) {
bool ret = true;
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
MyString buffer;
if ( ad->LookupString( CronTab::attributes[ctr], buffer ) ) {
MyString curError;
if ( !CronTab::validateParameter( ctr, buffer.Value(), curError ) ) {
ret = false;
error += curError;
}
}
} // FOR
return ( ret );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,266 | CronTab::validateParameter( int attribute_idx, const char *parameter,
MyString &error ) {
bool ret = true;
MyString temp(parameter);
if ( CronTab::regex.match( temp ) ) {
error = "Invalid parameter value '";
error += parameter;
error += "' for ";
error += CronTab::attributes[attribute_idx];
ret = false;
}
return ( ret );
}
| DoS Exec Code | 0 | CronTab::validateParameter( int attribute_idx, const char *parameter,
MyString &error ) {
bool ret = true;
MyString temp(parameter);
if ( CronTab::regex.match( temp ) ) {
error = "Invalid parameter value '";
error += parameter;
error += "' for ";
error += CronTab::attributes[attribute_idx];
ret = false;
}
return ( ret );
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,267 | CronTab::~CronTab() {
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
if ( this->ranges[ctr] ) delete this->ranges[ctr];
if ( this->parameters[ctr] ) delete this->parameters[ctr];
} // FOR
}
| DoS Exec Code | 0 | CronTab::~CronTab() {
int ctr;
for ( ctr = 0; ctr < CRONTAB_FIELDS; ctr++ ) {
if ( this->ranges[ctr] ) delete this->ranges[ctr];
if ( this->parameters[ctr] ) delete this->parameters[ctr];
} // FOR
}
| @@ -373,7 +373,7 @@ CronTab::initRegexObject() {
if ( ! CronTab::regex.compile( pattern, &errptr, &erroffset )) {
MyString error = "CronTab: Failed to compile Regex - ";
error += pattern;
- EXCEPT( const_cast<char*>(error.Value()));
+ EXCEPT( "%s", const_cast<char*>(error.Value()) );
}
}
} | CWE-134 | null | null |
13,268 | email_admin_open(const char *subject)
{
return email_open(NULL,subject);
}
| DoS Exec Code | 0 | email_admin_open(const char *subject)
{
return email_open(NULL,subject);
}
| @@ -433,7 +433,7 @@ email_close(FILE *mailer)
customSig = NULL;
if ((customSig = param("EMAIL_SIGNATURE")) != NULL) {
fprintf( mailer, "\n\n");
- fprintf( mailer, customSig);
+ fprintf( mailer, "%s", customSig);
fprintf( mailer, "\n");
free(customSig);
} else { | CWE-134 | null | null |
13,269 | email_developers_open(const char *subject)
{
char *tmp;
FILE *mailer;
/*
** According to the docs, if CONDOR_DEVELOPERS is not
** in the config file, it defaults to UW. If it is "NONE",
** nothing should be emailed.
*/
tmp = param ("CONDOR_DEVELOPERS");
if (tmp == NULL) {
/* we strdup here since we always call free below */
#ifdef NO_PHONE_HOME
tmp = strdup("NONE");
#else
tmp = strdup("condor-admin@cs.wisc.edu");
#endif
} else
if (strcasecmp (tmp, "NONE") == 0) {
free (tmp);
return NULL;
}
mailer = email_open(tmp,subject);
/* Don't forget to free tmp! */
free(tmp);
return mailer;
}
| DoS Exec Code | 0 | email_developers_open(const char *subject)
{
char *tmp;
FILE *mailer;
/*
** According to the docs, if CONDOR_DEVELOPERS is not
** in the config file, it defaults to UW. If it is "NONE",
** nothing should be emailed.
*/
tmp = param ("CONDOR_DEVELOPERS");
if (tmp == NULL) {
/* we strdup here since we always call free below */
#ifdef NO_PHONE_HOME
tmp = strdup("NONE");
#else
tmp = strdup("condor-admin@cs.wisc.edu");
#endif
} else
if (strcasecmp (tmp, "NONE") == 0) {
free (tmp);
return NULL;
}
mailer = email_open(tmp,subject);
/* Don't forget to free tmp! */
free(tmp);
return mailer;
}
| @@ -433,7 +433,7 @@ email_close(FILE *mailer)
customSig = NULL;
if ((customSig = param("EMAIL_SIGNATURE")) != NULL) {
fprintf( mailer, "\n\n");
- fprintf( mailer, customSig);
+ fprintf( mailer, "%s", customSig);
fprintf( mailer, "\n");
free(customSig);
} else { | CWE-134 | null | null |
13,270 | email_open( const char *email_addr, const char *subject )
{
char *Mailer;
char *SmtpServer = NULL;
char *FromAddress = NULL;
char *FinalSubject;
char *FinalAddr;
char *temp;
int token_boundary;
int num_addresses;
int arg_index;
FILE *mailerstream;
if ( (Mailer = param("MAIL")) == NULL ) {
dprintf(D_FULLDEBUG,
"Trying to email, but MAIL not specified in config file\n");
return NULL;
}
/* Take care of the subject. */
if ( subject ) {
size_t prolog_length = strlen(EMAIL_SUBJECT_PROLOG);
size_t subject_length = strlen(subject);
FinalSubject = (char *)malloc(prolog_length + subject_length + 1);
memcpy(FinalSubject, EMAIL_SUBJECT_PROLOG, prolog_length);
memcpy(&FinalSubject[prolog_length], subject, subject_length);
FinalSubject[prolog_length + subject_length] = '\0';
}
else {
FinalSubject = strdup(EMAIL_SUBJECT_PROLOG);
}
/** The following will not cause a fatal error, it just means
that on Windows we may construct an invalid "from" address. */
FromAddress = param("MAIL_FROM");
#ifdef WIN32
/* On WinNT, we need to be given an SMTP server, and we must pass
* this servername to the Mailer with a -relay option.
*/
if ( (SmtpServer=param("SMTP_SERVER")) == NULL ) {
dprintf(D_FULLDEBUG,
"Trying to email, but SMTP_SERVER not specified in config file\n");
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
return NULL;
}
#endif
/* Take care of destination email address. If it is NULL, grab
* the email of the Condor admin from the config file.
* We strdup this since we modify it (we split it into tokens so that
* each address is a separate argument to the mailer).
*/
if ( email_addr ) {
FinalAddr = strdup(email_addr);
} else {
if ( (FinalAddr = param("CONDOR_ADMIN")) == NULL ) {
dprintf(D_FULLDEBUG,
"Trying to email, but CONDOR_ADMIN not specified in config file\n");
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
if (SmtpServer) free(SmtpServer);
return NULL;
}
}
/* Now tokenize the list of addresses on commas and/or spaces (by replacing
* commas and spaces with nils). We also count the addresses here so we
* know how large to make our argument vector
*/
token_boundary = TRUE;
num_addresses = 0;
for (temp = FinalAddr; *temp != '\0'; temp++) {
if (*temp == ',' || *temp == ' ') {
*temp = '\0';
token_boundary = TRUE;
}
else if (token_boundary) {
num_addresses++;
token_boundary = FALSE;
}
}
if (num_addresses == 0) {
dprintf(D_FULLDEBUG, "Trying to email, but address list is empty\n");
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
if (SmtpServer) free(SmtpServer);
free(FinalAddr);
return NULL;
}
/* construct the argument vector for the mailer */
const char * * final_args;
final_args = (char const * *)malloc((8 + num_addresses) * sizeof(char*));
if (final_args == NULL) {
EXCEPT("Out of memory");
}
arg_index = 0;
final_args[arg_index++] = Mailer;
final_args[arg_index++] = "-s";
final_args[arg_index++] = FinalSubject;
if (FromAddress) {
final_args[arg_index++] = "-f";
final_args[arg_index++] = FromAddress;
}
if (SmtpServer) {
final_args[arg_index++] = "-relay";
final_args[arg_index++] = SmtpServer;
}
temp = FinalAddr;
for (;;) {
while (*temp == '\0') temp++;
final_args[arg_index++] = temp;
if (--num_addresses == 0) break;
while (*temp != '\0') temp++;
}
final_args[arg_index] = NULL;
/* NEW CODE */
/* open a FILE* so that the mail we get will end up from condor,
and not from root */
#ifdef WIN32
mailerstream = email_open_implementation(Mailer, final_args);
#else
mailerstream = email_open_implementation(final_args);
#endif
if ( mailerstream ) {
fprintf(mailerstream,"This is an automated email from the Condor "
"system\non machine \"%s\". Do not reply.\n\n",get_local_fqdn().Value());
}
/* free up everything we strdup-ed and param-ed, and return result */
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
if (SmtpServer) free(SmtpServer);
free(FinalAddr);
free(final_args);
return mailerstream;
}
| DoS Exec Code | 0 | email_open( const char *email_addr, const char *subject )
{
char *Mailer;
char *SmtpServer = NULL;
char *FromAddress = NULL;
char *FinalSubject;
char *FinalAddr;
char *temp;
int token_boundary;
int num_addresses;
int arg_index;
FILE *mailerstream;
if ( (Mailer = param("MAIL")) == NULL ) {
dprintf(D_FULLDEBUG,
"Trying to email, but MAIL not specified in config file\n");
return NULL;
}
/* Take care of the subject. */
if ( subject ) {
size_t prolog_length = strlen(EMAIL_SUBJECT_PROLOG);
size_t subject_length = strlen(subject);
FinalSubject = (char *)malloc(prolog_length + subject_length + 1);
memcpy(FinalSubject, EMAIL_SUBJECT_PROLOG, prolog_length);
memcpy(&FinalSubject[prolog_length], subject, subject_length);
FinalSubject[prolog_length + subject_length] = '\0';
}
else {
FinalSubject = strdup(EMAIL_SUBJECT_PROLOG);
}
/** The following will not cause a fatal error, it just means
that on Windows we may construct an invalid "from" address. */
FromAddress = param("MAIL_FROM");
#ifdef WIN32
/* On WinNT, we need to be given an SMTP server, and we must pass
* this servername to the Mailer with a -relay option.
*/
if ( (SmtpServer=param("SMTP_SERVER")) == NULL ) {
dprintf(D_FULLDEBUG,
"Trying to email, but SMTP_SERVER not specified in config file\n");
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
return NULL;
}
#endif
/* Take care of destination email address. If it is NULL, grab
* the email of the Condor admin from the config file.
* We strdup this since we modify it (we split it into tokens so that
* each address is a separate argument to the mailer).
*/
if ( email_addr ) {
FinalAddr = strdup(email_addr);
} else {
if ( (FinalAddr = param("CONDOR_ADMIN")) == NULL ) {
dprintf(D_FULLDEBUG,
"Trying to email, but CONDOR_ADMIN not specified in config file\n");
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
if (SmtpServer) free(SmtpServer);
return NULL;
}
}
/* Now tokenize the list of addresses on commas and/or spaces (by replacing
* commas and spaces with nils). We also count the addresses here so we
* know how large to make our argument vector
*/
token_boundary = TRUE;
num_addresses = 0;
for (temp = FinalAddr; *temp != '\0'; temp++) {
if (*temp == ',' || *temp == ' ') {
*temp = '\0';
token_boundary = TRUE;
}
else if (token_boundary) {
num_addresses++;
token_boundary = FALSE;
}
}
if (num_addresses == 0) {
dprintf(D_FULLDEBUG, "Trying to email, but address list is empty\n");
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
if (SmtpServer) free(SmtpServer);
free(FinalAddr);
return NULL;
}
/* construct the argument vector for the mailer */
const char * * final_args;
final_args = (char const * *)malloc((8 + num_addresses) * sizeof(char*));
if (final_args == NULL) {
EXCEPT("Out of memory");
}
arg_index = 0;
final_args[arg_index++] = Mailer;
final_args[arg_index++] = "-s";
final_args[arg_index++] = FinalSubject;
if (FromAddress) {
final_args[arg_index++] = "-f";
final_args[arg_index++] = FromAddress;
}
if (SmtpServer) {
final_args[arg_index++] = "-relay";
final_args[arg_index++] = SmtpServer;
}
temp = FinalAddr;
for (;;) {
while (*temp == '\0') temp++;
final_args[arg_index++] = temp;
if (--num_addresses == 0) break;
while (*temp != '\0') temp++;
}
final_args[arg_index] = NULL;
/* NEW CODE */
/* open a FILE* so that the mail we get will end up from condor,
and not from root */
#ifdef WIN32
mailerstream = email_open_implementation(Mailer, final_args);
#else
mailerstream = email_open_implementation(final_args);
#endif
if ( mailerstream ) {
fprintf(mailerstream,"This is an automated email from the Condor "
"system\non machine \"%s\". Do not reply.\n\n",get_local_fqdn().Value());
}
/* free up everything we strdup-ed and param-ed, and return result */
free(Mailer);
free(FinalSubject);
if (FromAddress) free(FromAddress);
if (SmtpServer) free(SmtpServer);
free(FinalAddr);
free(final_args);
return mailerstream;
}
| @@ -433,7 +433,7 @@ email_close(FILE *mailer)
customSig = NULL;
if ((customSig = param("EMAIL_SIGNATURE")) != NULL) {
fprintf( mailer, "\n\n");
- fprintf( mailer, customSig);
+ fprintf( mailer, "%s", customSig);
fprintf( mailer, "\n");
free(customSig);
} else { | CWE-134 | null | null |
13,271 | email_open_implementation( const char * final_args[])
{
FILE *mailerstream;
pid_t pid;
int pipefds[2];
param_functions *p_funcs = NULL;
/* The gist of this code is to exec a mailer whose stdin is dup2'ed onto
the write end of a pipe. The parent gets the fdopen'ed read end
so it looks like a FILE*. The child goes out of its
way to set its real uid to condor and prop up the environment so
that any mail that gets sent from the condor daemons ends up as
comming from the condor account instead of superuser.
On some OS'es, the child cannot write to the logs even though the
mailer process is ruid condor. So I turned off logging in the
child. I have no clue why this behaviour happens.
-pete 04/14/2000
*/
if (pipe(pipefds) < 0)
{
dprintf(D_ALWAYS, "Could not open email pipe!\n");
return NULL;
}
dprintf(D_FULLDEBUG, "Forking Mailer process...\n");
if ((pid = fork()) < 0)
{
dprintf(D_ALWAYS, "Could not fork email process!\n");
return NULL;
}
else if (pid > 0) /* parent */
{
/* SIGCLD, SIGPIPE are ignored elsewhere in the code.... */
/* close read end of pipe */
close(pipefds[0]);
mailerstream = fdopen(pipefds[1], EMAIL_POPEN_FLAGS);
if (mailerstream == NULL)
{
dprintf(D_ALWAYS, "Could not open email FILE*: %s\n",
strerror(errno));
return NULL;
}
return mailerstream;
}
else /* child mailer process */
{
static char pe_logname[256]; /* Sorry, putenv wants it this way */
static char pe_user[256];
const char *condor_name;
int i;
/* Disable any EXCEPT_Cleanup code installed by the parent process.
Otherwise, for example, in the master, any call to EXCEPT in
the following code will cause us to kill the master's children. */
_EXCEPT_Cleanup = NULL;
/* XXX This must be the FIRST thing in this block of code. For some
reason, at least on IRIX65, this forked process
will not be able to open the shadow lock file,
or be able to use dprintf or do any sort of
logging--even if the ruid hasn't changed. I do
not know why and this should be investigated. So
for now, I've turned off logging for this child
process. Thankfully it is a short piece of code
before the exec. -pete 03-05-2000
*/
Termlog = 1;
p_funcs = get_param_functions();
dprintf_config(get_mySubSystemName(), p_funcs);
/* this is a simple daemon that if it needs to stat . should be
able to. You might not be able to if the shadow's cwd is in the
user dir somewhere and not readable by the Condor Account. */
chdir("/");
umask(0);
/* Change my userid permanently to "condor" */
/* WARNING This code must happen before the close/dup operation. */
set_condor_priv_final();
/* close write end of pipe */
close(pipefds[1]);
/* connect the write end of the pipe to the stdin of the mailer */
if (dup2(pipefds[0], STDIN_FILENO) < 0)
{
/* I hope this EXCEPT gets recorded somewhere */
EXCEPT("EMAIL PROCESS: Could not connect stdin to child!\n");
}
/* close all other unneeded file descriptors including stdout and
stderr, just leave the stdin open to this process. */
for(i = 0; i < sysconf(_SC_OPEN_MAX); i++)
{
if (i != pipefds[0] && i != STDIN_FILENO)
{
(void)close(i);
}
}
/* prop up the environment with goodies to get the Mailer to do the
right thing */
condor_name = get_condor_username();
/* Should be snprintf() but we don't have it for all platforms */
sprintf(pe_logname,"LOGNAME=%s", condor_name);
if (putenv(pe_logname) != 0)
{
EXCEPT("EMAIL PROCESS: Unable to insert LOGNAME=%s into "
" environment correctly: %s\n", pe_logname, strerror(errno));
}
/* Should be snprintf() but we don't have it for all platforms */
sprintf(pe_user,"USER=%s", condor_name);
if( putenv(pe_user) != 0)
{
/* I hope this EXCEPT gets recorded somewhere */
EXCEPT("EMAIL PROCESS: Unable to insert USER=%s into "
" environment correctly: %s\n", pe_user, strerror(errno));
}
/* invoke the mailer */
execvp(final_args[0], const_cast<char *const*>(final_args) );
/* I hope this EXCEPT gets recorded somewhere */
EXCEPT("EMAIL PROCESS: Could not exec mailer using '%s' with command "
"'%s' because of error: %s.", "/bin/sh",
(final_args[0]==NULL)?"(null)":final_args[0], strerror(errno));
}
/* for completeness */
return NULL;
}
| DoS Exec Code | 0 | email_open_implementation( const char * final_args[])
{
FILE *mailerstream;
pid_t pid;
int pipefds[2];
param_functions *p_funcs = NULL;
/* The gist of this code is to exec a mailer whose stdin is dup2'ed onto
the write end of a pipe. The parent gets the fdopen'ed read end
so it looks like a FILE*. The child goes out of its
way to set its real uid to condor and prop up the environment so
that any mail that gets sent from the condor daemons ends up as
comming from the condor account instead of superuser.
On some OS'es, the child cannot write to the logs even though the
mailer process is ruid condor. So I turned off logging in the
child. I have no clue why this behaviour happens.
-pete 04/14/2000
*/
if (pipe(pipefds) < 0)
{
dprintf(D_ALWAYS, "Could not open email pipe!\n");
return NULL;
}
dprintf(D_FULLDEBUG, "Forking Mailer process...\n");
if ((pid = fork()) < 0)
{
dprintf(D_ALWAYS, "Could not fork email process!\n");
return NULL;
}
else if (pid > 0) /* parent */
{
/* SIGCLD, SIGPIPE are ignored elsewhere in the code.... */
/* close read end of pipe */
close(pipefds[0]);
mailerstream = fdopen(pipefds[1], EMAIL_POPEN_FLAGS);
if (mailerstream == NULL)
{
dprintf(D_ALWAYS, "Could not open email FILE*: %s\n",
strerror(errno));
return NULL;
}
return mailerstream;
}
else /* child mailer process */
{
static char pe_logname[256]; /* Sorry, putenv wants it this way */
static char pe_user[256];
const char *condor_name;
int i;
/* Disable any EXCEPT_Cleanup code installed by the parent process.
Otherwise, for example, in the master, any call to EXCEPT in
the following code will cause us to kill the master's children. */
_EXCEPT_Cleanup = NULL;
/* XXX This must be the FIRST thing in this block of code. For some
reason, at least on IRIX65, this forked process
will not be able to open the shadow lock file,
or be able to use dprintf or do any sort of
logging--even if the ruid hasn't changed. I do
not know why and this should be investigated. So
for now, I've turned off logging for this child
process. Thankfully it is a short piece of code
before the exec. -pete 03-05-2000
*/
Termlog = 1;
p_funcs = get_param_functions();
dprintf_config(get_mySubSystemName(), p_funcs);
/* this is a simple daemon that if it needs to stat . should be
able to. You might not be able to if the shadow's cwd is in the
user dir somewhere and not readable by the Condor Account. */
chdir("/");
umask(0);
/* Change my userid permanently to "condor" */
/* WARNING This code must happen before the close/dup operation. */
set_condor_priv_final();
/* close write end of pipe */
close(pipefds[1]);
/* connect the write end of the pipe to the stdin of the mailer */
if (dup2(pipefds[0], STDIN_FILENO) < 0)
{
/* I hope this EXCEPT gets recorded somewhere */
EXCEPT("EMAIL PROCESS: Could not connect stdin to child!\n");
}
/* close all other unneeded file descriptors including stdout and
stderr, just leave the stdin open to this process. */
for(i = 0; i < sysconf(_SC_OPEN_MAX); i++)
{
if (i != pipefds[0] && i != STDIN_FILENO)
{
(void)close(i);
}
}
/* prop up the environment with goodies to get the Mailer to do the
right thing */
condor_name = get_condor_username();
/* Should be snprintf() but we don't have it for all platforms */
sprintf(pe_logname,"LOGNAME=%s", condor_name);
if (putenv(pe_logname) != 0)
{
EXCEPT("EMAIL PROCESS: Unable to insert LOGNAME=%s into "
" environment correctly: %s\n", pe_logname, strerror(errno));
}
/* Should be snprintf() but we don't have it for all platforms */
sprintf(pe_user,"USER=%s", condor_name);
if( putenv(pe_user) != 0)
{
/* I hope this EXCEPT gets recorded somewhere */
EXCEPT("EMAIL PROCESS: Unable to insert USER=%s into "
" environment correctly: %s\n", pe_user, strerror(errno));
}
/* invoke the mailer */
execvp(final_args[0], const_cast<char *const*>(final_args) );
/* I hope this EXCEPT gets recorded somewhere */
EXCEPT("EMAIL PROCESS: Could not exec mailer using '%s' with command "
"'%s' because of error: %s.", "/bin/sh",
(final_args[0]==NULL)?"(null)":final_args[0], strerror(errno));
}
/* for completeness */
return NULL;
}
| @@ -433,7 +433,7 @@ email_close(FILE *mailer)
customSig = NULL;
if ((customSig = param("EMAIL_SIGNATURE")) != NULL) {
fprintf( mailer, "\n\n");
- fprintf( mailer, customSig);
+ fprintf( mailer, "%s", customSig);
fprintf( mailer, "\n");
free(customSig);
} else { | CWE-134 | null | null |
13,272 | EventHandler::allow_events( sigset_t &sigset )
{
if( !is_installed ) {
EXCEPT( "ERROR EventHandler::allow_events(), not installed");
}
sigprocmask( SIG_UNBLOCK, &sigset, 0 );
}
| DoS Exec Code | 0 | EventHandler::allow_events( sigset_t &sigset )
{
if( !is_installed ) {
EXCEPT( "ERROR EventHandler::allow_events(), not installed");
}
sigprocmask( SIG_UNBLOCK, &sigset, 0 );
}
| @@ -80,7 +80,7 @@ display_sigset( const char *msg, sigset_t *mask )
NameTableIterator next_sig( SigNames );
if( msg ) {
- dprintf( D_ALWAYS, msg );
+ dprintf( D_ALWAYS, "%s", msg );
}
while( (signo = next_sig()) != -1 ) {
if( sigismember(mask,signo) ) { | CWE-134 | null | null |
13,273 | EventHandler::block_events( sigset_t &sigset )
{
if( !is_installed ) {
EXCEPT( "ERROR EventHandler::block_events(), not installed");
}
sigprocmask( SIG_BLOCK, &sigset, 0 );
}
| DoS Exec Code | 0 | EventHandler::block_events( sigset_t &sigset )
{
if( !is_installed ) {
EXCEPT( "ERROR EventHandler::block_events(), not installed");
}
sigprocmask( SIG_BLOCK, &sigset, 0 );
}
| @@ -80,7 +80,7 @@ display_sigset( const char *msg, sigset_t *mask )
NameTableIterator next_sig( SigNames );
if( msg ) {
- dprintf( D_ALWAYS, msg );
+ dprintf( D_ALWAYS, "%s", msg );
}
while( (signo = next_sig()) != -1 ) {
if( sigismember(mask,signo) ) { | CWE-134 | null | null |
13,274 | EventHandler::display()
{
dprintf( D_ALWAYS, "EventHandler {\n" );
dprintf( D_ALWAYS, "\tfunc = %p\n", func );
display_sigset( "\tmask = ", &mask );
dprintf( D_ALWAYS, "}\n" );
}
| DoS Exec Code | 0 | EventHandler::display()
{
dprintf( D_ALWAYS, "EventHandler {\n" );
dprintf( D_ALWAYS, "\tfunc = %p\n", func );
display_sigset( "\tmask = ", &mask );
dprintf( D_ALWAYS, "}\n" );
}
| @@ -80,7 +80,7 @@ display_sigset( const char *msg, sigset_t *mask )
NameTableIterator next_sig( SigNames );
if( msg ) {
- dprintf( D_ALWAYS, msg );
+ dprintf( D_ALWAYS, "%s", msg );
}
while( (signo = next_sig()) != -1 ) {
if( sigismember(mask,signo) ) { | CWE-134 | null | null |
13,275 | EventHandler::install()
{
NameTableIterator next_sig( SigNames );
struct sigaction action;
int i;
int signo;
dprintf( D_FULLDEBUG, "EventHandler::install() {\n" );
if( is_installed ) {
EXCEPT( "ERROR EventHandler::install(), already installed" );
}
for( i=0; i<N_POSIX_SIGS; i++ ) {
signo = next_sig();
if( sigismember(&mask,signo) ) {
#if (defined(LINUX) && !defined(GLIBC20) && !defined(GLIBC21)) || defined(AIX) || defined(HPUX11) || defined(CONDOR_FREEBSD) || defined(Darwin) || defined(Solaris)
action.sa_handler = func;
#else
action.sa_handler = (void (*)(...)) func;
#endif
action.sa_mask = mask;
action.sa_flags = SA_NOCLDSTOP;
if( sigaction(signo,&action,&o_action[i]) < 0 ) {
perror( "sigaction" );
exit( 1 );
}
dprintf( D_FULLDEBUG,
"\t*FSM* Installed handler %p for signal %s, flags = 0x%x\n",
action.sa_handler, SigNames.get_name(signo), action.sa_flags
);
}
}
is_installed = TRUE;
dprintf( D_FULLDEBUG, "}\n" );
}
| DoS Exec Code | 0 | EventHandler::install()
{
NameTableIterator next_sig( SigNames );
struct sigaction action;
int i;
int signo;
dprintf( D_FULLDEBUG, "EventHandler::install() {\n" );
if( is_installed ) {
EXCEPT( "ERROR EventHandler::install(), already installed" );
}
for( i=0; i<N_POSIX_SIGS; i++ ) {
signo = next_sig();
if( sigismember(&mask,signo) ) {
#if (defined(LINUX) && !defined(GLIBC20) && !defined(GLIBC21)) || defined(AIX) || defined(HPUX11) || defined(CONDOR_FREEBSD) || defined(Darwin) || defined(Solaris)
action.sa_handler = func;
#else
action.sa_handler = (void (*)(...)) func;
#endif
action.sa_mask = mask;
action.sa_flags = SA_NOCLDSTOP;
if( sigaction(signo,&action,&o_action[i]) < 0 ) {
perror( "sigaction" );
exit( 1 );
}
dprintf( D_FULLDEBUG,
"\t*FSM* Installed handler %p for signal %s, flags = 0x%x\n",
action.sa_handler, SigNames.get_name(signo), action.sa_flags
);
}
}
is_installed = TRUE;
dprintf( D_FULLDEBUG, "}\n" );
}
| @@ -80,7 +80,7 @@ display_sigset( const char *msg, sigset_t *mask )
NameTableIterator next_sig( SigNames );
if( msg ) {
- dprintf( D_ALWAYS, msg );
+ dprintf( D_ALWAYS, "%s", msg );
}
while( (signo = next_sig()) != -1 ) {
if( sigismember(mask,signo) ) { | CWE-134 | null | null |
13,276 | FileTransfer::AddDownloadFilenameRemap(char const *source_name,char const *target_name) {
if(!download_filename_remaps.IsEmpty()) {
download_filename_remaps += ";";
}
download_filename_remaps += source_name;
download_filename_remaps += "=";
download_filename_remaps += target_name;
}
| DoS Exec Code | 0 | FileTransfer::AddDownloadFilenameRemap(char const *source_name,char const *target_name) {
if(!download_filename_remaps.IsEmpty()) {
download_filename_remaps += ";";
}
download_filename_remaps += source_name;
download_filename_remaps += "=";
download_filename_remaps += target_name;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,277 | FileTransfer::AddDownloadFilenameRemaps(char const *remaps) {
if(!download_filename_remaps.IsEmpty()) {
download_filename_remaps += ";";
}
download_filename_remaps += remaps;
}
| DoS Exec Code | 0 | FileTransfer::AddDownloadFilenameRemaps(char const *remaps) {
if(!download_filename_remaps.IsEmpty()) {
download_filename_remaps += ";";
}
download_filename_remaps += remaps;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,278 | FileTransfer::CommitFiles()
{
MyString buf;
MyString newbuf;
MyString swapbuf;
const char *file;
if ( IsClient() ) {
return;
}
int cluster = -1;
int proc = -1;
jobAd.LookupInteger(ATTR_CLUSTER_ID, cluster);
jobAd.LookupInteger(ATTR_PROC_ID, proc);
priv_state saved_priv = PRIV_UNKNOWN;
if( want_priv_change ) {
saved_priv = set_priv( desired_priv_state );
}
Directory tmpspool( TmpSpoolSpace, desired_priv_state );
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,COMMIT_FILENAME);
if ( access(buf.Value(),F_OK) >= 0 ) {
MyString SwapSpoolSpace;
SwapSpoolSpace.sprintf("%s.swap",SpoolSpace);
bool swap_dir_ready = SpooledJobFiles::createJobSwapSpoolDirectory(&jobAd,desired_priv_state);
if( !swap_dir_ready ) {
EXCEPT("Failed to create %s",SwapSpoolSpace.Value());
}
while ( (file=tmpspool.Next()) ) {
if ( file_strcmp(file,COMMIT_FILENAME) == MATCH )
continue;
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,file);
newbuf.sprintf("%s%c%s",SpoolSpace,DIR_DELIM_CHAR,file);
swapbuf.sprintf("%s%c%s",SwapSpoolSpace.Value(),DIR_DELIM_CHAR,file);
if( access(newbuf.Value(),F_OK) >= 0 ) {
if ( rename(newbuf.Value(),swapbuf.Value()) < 0 ) {
EXCEPT("FileTransfer CommitFiles failed to move %s to %s: %s",newbuf.Value(),swapbuf.Value(),strerror(errno));
}
}
if ( rotate_file(buf.Value(),newbuf.Value()) < 0 ) {
EXCEPT("FileTransfer CommitFiles Failed -- What Now?!?!");
}
}
SpooledJobFiles::removeJobSwapSpoolDirectory(cluster,proc);
}
tmpspool.Remove_Entire_Directory();
if( want_priv_change ) {
ASSERT( saved_priv != PRIV_UNKNOWN );
set_priv( saved_priv );
}
}
| DoS Exec Code | 0 | FileTransfer::CommitFiles()
{
MyString buf;
MyString newbuf;
MyString swapbuf;
const char *file;
if ( IsClient() ) {
return;
}
int cluster = -1;
int proc = -1;
jobAd.LookupInteger(ATTR_CLUSTER_ID, cluster);
jobAd.LookupInteger(ATTR_PROC_ID, proc);
priv_state saved_priv = PRIV_UNKNOWN;
if( want_priv_change ) {
saved_priv = set_priv( desired_priv_state );
}
Directory tmpspool( TmpSpoolSpace, desired_priv_state );
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,COMMIT_FILENAME);
if ( access(buf.Value(),F_OK) >= 0 ) {
MyString SwapSpoolSpace;
SwapSpoolSpace.sprintf("%s.swap",SpoolSpace);
bool swap_dir_ready = SpooledJobFiles::createJobSwapSpoolDirectory(&jobAd,desired_priv_state);
if( !swap_dir_ready ) {
EXCEPT("Failed to create %s",SwapSpoolSpace.Value());
}
while ( (file=tmpspool.Next()) ) {
if ( file_strcmp(file,COMMIT_FILENAME) == MATCH )
continue;
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,file);
newbuf.sprintf("%s%c%s",SpoolSpace,DIR_DELIM_CHAR,file);
swapbuf.sprintf("%s%c%s",SwapSpoolSpace.Value(),DIR_DELIM_CHAR,file);
if( access(newbuf.Value(),F_OK) >= 0 ) {
if ( rename(newbuf.Value(),swapbuf.Value()) < 0 ) {
EXCEPT("FileTransfer CommitFiles failed to move %s to %s: %s",newbuf.Value(),swapbuf.Value(),strerror(errno));
}
}
if ( rotate_file(buf.Value(),newbuf.Value()) < 0 ) {
EXCEPT("FileTransfer CommitFiles Failed -- What Now?!?!");
}
}
SpooledJobFiles::removeJobSwapSpoolDirectory(cluster,proc);
}
tmpspool.Remove_Entire_Directory();
if( want_priv_change ) {
ASSERT( saved_priv != PRIV_UNKNOWN );
set_priv( saved_priv );
}
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,279 | FileTransfer::Continue()
{
int result = TRUE; // return TRUE if there currently is no thread
if (ActiveTransferTid != -1 ) {
ASSERT( daemonCore );
result = daemonCore->Continue_Thread(ActiveTransferTid);
}
return result;
}
| DoS Exec Code | 0 | FileTransfer::Continue()
{
int result = TRUE; // return TRUE if there currently is no thread
if (ActiveTransferTid != -1 ) {
ASSERT( daemonCore );
result = daemonCore->Continue_Thread(ActiveTransferTid);
}
return result;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,280 | FileTransfer::DoDownload( filesize_t *total_bytes, ReliSock *s)
{
int rc;
int reply = 0;
filesize_t bytes=0;
MyString filename;;
MyString fullname;
char *tmp_buf = NULL;
int final_transfer = 0;
bool download_success = true;
bool try_again = true;
int hold_code = 0;
int hold_subcode = 0;
MyString error_buf;
int delegation_method = 0; /* 0 means this transfer is not a delegation. 1 means it is.*/
time_t start, elapsed;
bool I_go_ahead_always = false;
bool peer_goes_ahead_always = false;
DCTransferQueue xfer_queue(m_xfer_queue_contact_info);
CondorError errstack;
priv_state saved_priv = PRIV_UNKNOWN;
*total_bytes = 0;
bool want_fsync = ( ((IsClient() && !simple_init) || // starter receiving
(IsServer() && simple_init)) // schedd receiving
&& upload_changed_files );
dprintf(D_FULLDEBUG,"entering FileTransfer::DoDownload sync=%d\n",
want_fsync ? 1 : 0);
s->decode();
bool socket_default_crypto = s->get_encryption();
if( !s->code(final_transfer) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !s->end_of_message() ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !final_transfer && IsServer() ) {
SpooledJobFiles::createJobSpoolDirectory(&jobAd,desired_priv_state);
}
for (;;) {
if( !s->code(reply) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !s->end_of_message() ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
dprintf( D_SECURITY, "FILETRANSFER: incoming file_command is %i\n", reply);
if( !reply ) {
break;
}
if (reply == 2) {
s->set_crypto_mode(true);
} else if (reply == 3) {
s->set_crypto_mode(false);
}
else {
s->set_crypto_mode(socket_default_crypto);
}
tmp_buf = NULL;
if( !s->code(tmp_buf) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
filename = tmp_buf;
free( tmp_buf );
tmp_buf = NULL;
/*
if we want to change priv states but haven't done so
yet, set it now. we only need to do this once since
we're no longer doing any hard-coded insanity with
PRIV_CONDOR and everything can either be done in our
existing priv state (want_priv_change == FALSE) or in
the priv state we were told to use... Derek, 2005-04-21
*/
if( want_priv_change && saved_priv == PRIV_UNKNOWN ) {
saved_priv = set_priv( desired_priv_state );
}
if( !LegalPathInSandbox(filename.Value(),Iwd) ) {
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = EPERM;
error_buf.sprintf_cat(
" Attempt to write to illegal sandbox path: %s",
filename.Value());
dprintf(D_ALWAYS,"DoDownload: attempt to write to illegal sandbox path by our peer %s: %s.\n",
s->peer_description(),
filename.Value());
filename = NULL_FILE;
}
if( !strcmp(filename.Value(),NULL_FILE) ) {
fullname = filename;
}
else if( final_transfer || IsClient() ) {
MyString remap_filename;
if(filename_remap_find(download_filename_remaps.Value(),filename.Value(),remap_filename)) {
if(!is_relative_to_cwd(remap_filename.Value())) {
fullname = remap_filename;
}
else {
fullname.sprintf("%s%c%s",Iwd,DIR_DELIM_CHAR,remap_filename.Value());
}
dprintf(D_FULLDEBUG,"Remapped downloaded file from %s to %s\n",filename.Value(),remap_filename.Value());
}
else {
fullname.sprintf("%s%c%s",Iwd,DIR_DELIM_CHAR,filename.Value());
}
#ifdef WIN32
if ( perm_obj && (perm_obj->write_access(fullname.Value()) != 1) ) {
error_buf.sprintf("Permission denied to write file %s!",
fullname.Value());
dprintf(D_ALWAYS,"DoDownload: %s\n",error_buf.Value());
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = EPERM;
fullname = NULL_FILE;
}
#endif
} else {
fullname.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,filename.Value());
}
if( PeerDoesGoAhead ) {
if( !s->end_of_message() ) {
dprintf(D_FULLDEBUG,"DoDownload: failed on eom before GoAhead: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !I_go_ahead_always ) {
if( !ObtainAndSendTransferGoAhead(xfer_queue,true,s,fullname.Value(),I_go_ahead_always) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
}
if( !peer_goes_ahead_always ) {
if( !ReceiveTransferGoAhead(s,fullname.Value(),true,peer_goes_ahead_always) ) {
dprintf(D_FULLDEBUG, "DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
}
s->decode();
}
start = time(NULL);
if (reply == 999) {
ClassAd file_info;
if (!file_info.initFromStream(*s)) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
int subcommand = 0;
if(!file_info.LookupInteger("Result",subcommand)) {
subcommand = -1;
}
if(subcommand == 7) {
MyString rt_src;
MyString rt_dst;
MyString rt_err;
int rt_result = 0;
if(!file_info.LookupInteger("Result",rt_result)) {
rt_result = -1;
}
if(!file_info.LookupString("Filename", rt_src)) {
rt_src = "<null>";
}
if(!file_info.LookupString("OutputDestination", rt_dst)) {
rt_dst = "<null>";
}
if(!file_info.LookupString("ErrorString", rt_err)) {
rt_err = "<null>";
}
dprintf(D_ALWAYS, "DoDownload: other side transferred %s to %s and got result %i\n",
rt_src.Value(), rt_dst.Value(), rt_result );
if(rt_result == 0) {
rc = 0;
} else {
rc = 0;
error_buf.sprintf(
"%s at %s failed due to remote transfer hook error: %s",
get_mySubSystem()->getName(),
s->my_ip_str(),fullname.Value());
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = rt_result;
dprintf(D_ALWAYS,
"DoDownload: consuming rest of transfer and failing "
"after encountering the following error: %s\n",
error_buf.Value());
}
} else {
dprintf(D_ALWAYS, "FILETRANSFER: unrecognized subcommand %i! skipping!\n", subcommand);
file_info.dPrint(D_FULLDEBUG);
rc = 0;
}
} else if (reply == 5) {
MyString URL;
if (!s->code(URL)) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
dprintf( D_FULLDEBUG, "DoDownload: doing a URL transfer: (%s) to (%s)\n", URL.Value(), fullname.Value());
rc = InvokeFileTransferPlugin(errstack, URL.Value(), fullname.Value(), LocalProxyName.Value());
} else if ( reply == 4 ) {
if ( PeerDoesGoAhead || s->end_of_message() ) {
rc = s->get_x509_delegation( &bytes, fullname.Value() );
dprintf( D_FULLDEBUG,
"DoDownload: get_x509_delegation() returned %d\n",
rc );
if (rc == 0) {
LocalProxyName = fullname;
}
} else {
rc = -1;
}
delegation_method = 1;/* This is a delegation, unseuccessful or not */
} else if( reply == 6 ) { // mkdir
condor_mode_t file_mode = NULL_FILE_PERMISSIONS;
if( !s->code(file_mode) ) {
rc = -1;
dprintf(D_ALWAYS,"DoDownload: failed to read mkdir mode.\n");
}
else {
rc = mkdir(fullname.Value(),file_mode);
if( rc == -1 && errno == EEXIST ) {
StatInfo st( fullname.Value() );
if( !st.Error() && st.IsDirectory() ) {
dprintf(D_FULLDEBUG,"Requested to create directory but using existing one: %s\n",fullname.Value());
rc = 0;
}
else if( !strcmp(fullname.Value(),NULL_FILE) ) {
rc = 0;
}
else {
remove(fullname.Value());
rc = mkdir(fullname.Value(),file_mode);
}
}
if( rc == -1 ) {
rc = 0;
int the_error = errno;
error_buf.sprintf(
"%s at %s failed to create directory %s: %s (errno %d)",
get_mySubSystem()->getName(),
s->my_ip_str(),fullname.Value(),
strerror(the_error),the_error);
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = the_error;
dprintf(D_ALWAYS,
"DoDownload: consuming rest of transfer and failing "
"after encountering the following error: %s\n",
error_buf.Value());
}
}
} else if ( TransferFilePermissions ) {
rc = s->get_file_with_permissions( &bytes, fullname.Value() );
} else {
rc = s->get_file( &bytes, fullname.Value() );
}
elapsed = time(NULL)-start;
if( rc < 0 ) {
int the_error = errno;
error_buf.sprintf("%s at %s failed to receive file %s",
get_mySubSystem()->getName(),
s->my_ip_str(),fullname.Value());
download_success = false;
if(rc == GET_FILE_OPEN_FAILED || rc == GET_FILE_WRITE_FAILED ||
rc == GET_FILE_PLUGIN_FAILED) {
if (rc == GET_FILE_PLUGIN_FAILED) {
error_buf.sprintf_cat(": %s", errstack.getFullText());
} else {
error_buf.replaceString("receive","write to");
error_buf.sprintf_cat(": (errno %d) %s",the_error,strerror(the_error));
}
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = the_error;
dprintf(D_ALWAYS,
"DoDownload: consuming rest of transfer and failing "
"after encountering the following error: %s\n",
error_buf.Value());
}
else {
try_again = true;
dprintf(D_ALWAYS,"DoDownload: %s\n",error_buf.Value());
SendTransferAck(s,download_success,try_again,hold_code,hold_subcode,error_buf.Value());
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
}
if ( want_fsync ) {
struct utimbuf timewrap;
time_t current_time = time(NULL);
timewrap.actime = current_time; // set access time to now
timewrap.modtime = current_time - 180; // set modify time to 3 min ago
utime(fullname.Value(),&timewrap);
}
if( !s->end_of_message() ) {
return_and_resetpriv( -1 );
}
*total_bytes += bytes;
#ifdef HAVE_EXT_POSTGRESQL
file_transfer_record record;
record.fullname = fullname.Value();
record.bytes = bytes;
record.elapsed = elapsed;
char daemon[16]; daemon[15] = '\0';
strncpy(daemon, get_mySubSystem()->getName(), 15);
record.daemon = daemon;
record.sockp =s;
record.transfer_time = start;
record.delegation_method_id = delegation_method;
file_transfer_db(&record, &jobAd);
#else
if (delegation_method) {}
if (elapsed) {}
#endif
}
s->set_crypto_mode(socket_default_crypto);
#ifdef WIN32
bytesRcvd += (float)(signed __int64)(*total_bytes);
#else
bytesRcvd += (*total_bytes);
#endif
bool upload_success = false;
MyString upload_error_buf;
bool upload_try_again = true;
int upload_hold_code = 0;
int upload_hold_subcode = 0;
GetTransferAck(s,upload_success,upload_try_again,upload_hold_code,
upload_hold_subcode,upload_error_buf);
if(!upload_success) {
char const *peer_ip_str = "disconnected socket";
if(s->type() == Stream::reli_sock) {
peer_ip_str = ((Sock *)s)->get_sinful_peer();
}
MyString download_error_buf;
download_error_buf.sprintf("%s failed to receive file(s) from %s",
get_mySubSystem()->getName(),peer_ip_str);
error_buf.sprintf("%s; %s",
upload_error_buf.Value(),
download_error_buf.Value());
dprintf(D_ALWAYS,"DoDownload: %s\n",error_buf.Value());
download_success = false;
SendTransferAck(s,download_success,upload_try_again,upload_hold_code,
upload_hold_subcode,download_error_buf.Value());
Info.error_desc = error_buf.Value();
dprintf( D_FULLDEBUG, "DoDownload: exiting with upload errors\n" );
return_and_resetpriv( -1 );
}
if( !download_success ) {
SendTransferAck(s,download_success,try_again,hold_code,
hold_subcode,error_buf.Value());
dprintf( D_FULLDEBUG, "DoDownload: exiting with download errors\n" );
return_and_resetpriv( -1 );
}
if ( !final_transfer && IsServer() ) {
MyString buf;
int fd;
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,COMMIT_FILENAME);
#if defined(WIN32)
if ((fd = safe_open_wrapper_follow(buf.Value(), O_WRONLY | O_CREAT | O_TRUNC |
_O_BINARY | _O_SEQUENTIAL, 0644)) < 0)
#else
if ((fd = safe_open_wrapper_follow(buf.Value(), O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
#endif
{
dprintf(D_ALWAYS,
"FileTransfer::DoDownload failed to write commit file\n");
return_and_resetpriv( -1 );
}
::close(fd);
CommitFiles();
}
download_success = true;
SendTransferAck(s,download_success,try_again,hold_code,hold_subcode,NULL);
return_and_resetpriv( 0 );
}
| DoS Exec Code | 0 | FileTransfer::DoDownload( filesize_t *total_bytes, ReliSock *s)
{
int rc;
int reply = 0;
filesize_t bytes=0;
MyString filename;;
MyString fullname;
char *tmp_buf = NULL;
int final_transfer = 0;
bool download_success = true;
bool try_again = true;
int hold_code = 0;
int hold_subcode = 0;
MyString error_buf;
int delegation_method = 0; /* 0 means this transfer is not a delegation. 1 means it is.*/
time_t start, elapsed;
bool I_go_ahead_always = false;
bool peer_goes_ahead_always = false;
DCTransferQueue xfer_queue(m_xfer_queue_contact_info);
CondorError errstack;
priv_state saved_priv = PRIV_UNKNOWN;
*total_bytes = 0;
bool want_fsync = ( ((IsClient() && !simple_init) || // starter receiving
(IsServer() && simple_init)) // schedd receiving
&& upload_changed_files );
dprintf(D_FULLDEBUG,"entering FileTransfer::DoDownload sync=%d\n",
want_fsync ? 1 : 0);
s->decode();
bool socket_default_crypto = s->get_encryption();
if( !s->code(final_transfer) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !s->end_of_message() ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !final_transfer && IsServer() ) {
SpooledJobFiles::createJobSpoolDirectory(&jobAd,desired_priv_state);
}
for (;;) {
if( !s->code(reply) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !s->end_of_message() ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
dprintf( D_SECURITY, "FILETRANSFER: incoming file_command is %i\n", reply);
if( !reply ) {
break;
}
if (reply == 2) {
s->set_crypto_mode(true);
} else if (reply == 3) {
s->set_crypto_mode(false);
}
else {
s->set_crypto_mode(socket_default_crypto);
}
tmp_buf = NULL;
if( !s->code(tmp_buf) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
filename = tmp_buf;
free( tmp_buf );
tmp_buf = NULL;
/*
if we want to change priv states but haven't done so
yet, set it now. we only need to do this once since
we're no longer doing any hard-coded insanity with
PRIV_CONDOR and everything can either be done in our
existing priv state (want_priv_change == FALSE) or in
the priv state we were told to use... Derek, 2005-04-21
*/
if( want_priv_change && saved_priv == PRIV_UNKNOWN ) {
saved_priv = set_priv( desired_priv_state );
}
if( !LegalPathInSandbox(filename.Value(),Iwd) ) {
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = EPERM;
error_buf.sprintf_cat(
" Attempt to write to illegal sandbox path: %s",
filename.Value());
dprintf(D_ALWAYS,"DoDownload: attempt to write to illegal sandbox path by our peer %s: %s.\n",
s->peer_description(),
filename.Value());
filename = NULL_FILE;
}
if( !strcmp(filename.Value(),NULL_FILE) ) {
fullname = filename;
}
else if( final_transfer || IsClient() ) {
MyString remap_filename;
if(filename_remap_find(download_filename_remaps.Value(),filename.Value(),remap_filename)) {
if(!is_relative_to_cwd(remap_filename.Value())) {
fullname = remap_filename;
}
else {
fullname.sprintf("%s%c%s",Iwd,DIR_DELIM_CHAR,remap_filename.Value());
}
dprintf(D_FULLDEBUG,"Remapped downloaded file from %s to %s\n",filename.Value(),remap_filename.Value());
}
else {
fullname.sprintf("%s%c%s",Iwd,DIR_DELIM_CHAR,filename.Value());
}
#ifdef WIN32
if ( perm_obj && (perm_obj->write_access(fullname.Value()) != 1) ) {
error_buf.sprintf("Permission denied to write file %s!",
fullname.Value());
dprintf(D_ALWAYS,"DoDownload: %s\n",error_buf.Value());
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = EPERM;
fullname = NULL_FILE;
}
#endif
} else {
fullname.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,filename.Value());
}
if( PeerDoesGoAhead ) {
if( !s->end_of_message() ) {
dprintf(D_FULLDEBUG,"DoDownload: failed on eom before GoAhead: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
if( !I_go_ahead_always ) {
if( !ObtainAndSendTransferGoAhead(xfer_queue,true,s,fullname.Value(),I_go_ahead_always) ) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
}
if( !peer_goes_ahead_always ) {
if( !ReceiveTransferGoAhead(s,fullname.Value(),true,peer_goes_ahead_always) ) {
dprintf(D_FULLDEBUG, "DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
}
s->decode();
}
start = time(NULL);
if (reply == 999) {
ClassAd file_info;
if (!file_info.initFromStream(*s)) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
int subcommand = 0;
if(!file_info.LookupInteger("Result",subcommand)) {
subcommand = -1;
}
if(subcommand == 7) {
MyString rt_src;
MyString rt_dst;
MyString rt_err;
int rt_result = 0;
if(!file_info.LookupInteger("Result",rt_result)) {
rt_result = -1;
}
if(!file_info.LookupString("Filename", rt_src)) {
rt_src = "<null>";
}
if(!file_info.LookupString("OutputDestination", rt_dst)) {
rt_dst = "<null>";
}
if(!file_info.LookupString("ErrorString", rt_err)) {
rt_err = "<null>";
}
dprintf(D_ALWAYS, "DoDownload: other side transferred %s to %s and got result %i\n",
rt_src.Value(), rt_dst.Value(), rt_result );
if(rt_result == 0) {
rc = 0;
} else {
rc = 0;
error_buf.sprintf(
"%s at %s failed due to remote transfer hook error: %s",
get_mySubSystem()->getName(),
s->my_ip_str(),fullname.Value());
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = rt_result;
dprintf(D_ALWAYS,
"DoDownload: consuming rest of transfer and failing "
"after encountering the following error: %s\n",
error_buf.Value());
}
} else {
dprintf(D_ALWAYS, "FILETRANSFER: unrecognized subcommand %i! skipping!\n", subcommand);
file_info.dPrint(D_FULLDEBUG);
rc = 0;
}
} else if (reply == 5) {
MyString URL;
if (!s->code(URL)) {
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
dprintf( D_FULLDEBUG, "DoDownload: doing a URL transfer: (%s) to (%s)\n", URL.Value(), fullname.Value());
rc = InvokeFileTransferPlugin(errstack, URL.Value(), fullname.Value(), LocalProxyName.Value());
} else if ( reply == 4 ) {
if ( PeerDoesGoAhead || s->end_of_message() ) {
rc = s->get_x509_delegation( &bytes, fullname.Value() );
dprintf( D_FULLDEBUG,
"DoDownload: get_x509_delegation() returned %d\n",
rc );
if (rc == 0) {
LocalProxyName = fullname;
}
} else {
rc = -1;
}
delegation_method = 1;/* This is a delegation, unseuccessful or not */
} else if( reply == 6 ) { // mkdir
condor_mode_t file_mode = NULL_FILE_PERMISSIONS;
if( !s->code(file_mode) ) {
rc = -1;
dprintf(D_ALWAYS,"DoDownload: failed to read mkdir mode.\n");
}
else {
rc = mkdir(fullname.Value(),file_mode);
if( rc == -1 && errno == EEXIST ) {
StatInfo st( fullname.Value() );
if( !st.Error() && st.IsDirectory() ) {
dprintf(D_FULLDEBUG,"Requested to create directory but using existing one: %s\n",fullname.Value());
rc = 0;
}
else if( !strcmp(fullname.Value(),NULL_FILE) ) {
rc = 0;
}
else {
remove(fullname.Value());
rc = mkdir(fullname.Value(),file_mode);
}
}
if( rc == -1 ) {
rc = 0;
int the_error = errno;
error_buf.sprintf(
"%s at %s failed to create directory %s: %s (errno %d)",
get_mySubSystem()->getName(),
s->my_ip_str(),fullname.Value(),
strerror(the_error),the_error);
download_success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = the_error;
dprintf(D_ALWAYS,
"DoDownload: consuming rest of transfer and failing "
"after encountering the following error: %s\n",
error_buf.Value());
}
}
} else if ( TransferFilePermissions ) {
rc = s->get_file_with_permissions( &bytes, fullname.Value() );
} else {
rc = s->get_file( &bytes, fullname.Value() );
}
elapsed = time(NULL)-start;
if( rc < 0 ) {
int the_error = errno;
error_buf.sprintf("%s at %s failed to receive file %s",
get_mySubSystem()->getName(),
s->my_ip_str(),fullname.Value());
download_success = false;
if(rc == GET_FILE_OPEN_FAILED || rc == GET_FILE_WRITE_FAILED ||
rc == GET_FILE_PLUGIN_FAILED) {
if (rc == GET_FILE_PLUGIN_FAILED) {
error_buf.sprintf_cat(": %s", errstack.getFullText());
} else {
error_buf.replaceString("receive","write to");
error_buf.sprintf_cat(": (errno %d) %s",the_error,strerror(the_error));
}
try_again = false;
hold_code = CONDOR_HOLD_CODE_DownloadFileError;
hold_subcode = the_error;
dprintf(D_ALWAYS,
"DoDownload: consuming rest of transfer and failing "
"after encountering the following error: %s\n",
error_buf.Value());
}
else {
try_again = true;
dprintf(D_ALWAYS,"DoDownload: %s\n",error_buf.Value());
SendTransferAck(s,download_success,try_again,hold_code,hold_subcode,error_buf.Value());
dprintf(D_FULLDEBUG,"DoDownload: exiting at %d\n",__LINE__);
return_and_resetpriv( -1 );
}
}
if ( want_fsync ) {
struct utimbuf timewrap;
time_t current_time = time(NULL);
timewrap.actime = current_time; // set access time to now
timewrap.modtime = current_time - 180; // set modify time to 3 min ago
utime(fullname.Value(),&timewrap);
}
if( !s->end_of_message() ) {
return_and_resetpriv( -1 );
}
*total_bytes += bytes;
#ifdef HAVE_EXT_POSTGRESQL
file_transfer_record record;
record.fullname = fullname.Value();
record.bytes = bytes;
record.elapsed = elapsed;
char daemon[16]; daemon[15] = '\0';
strncpy(daemon, get_mySubSystem()->getName(), 15);
record.daemon = daemon;
record.sockp =s;
record.transfer_time = start;
record.delegation_method_id = delegation_method;
file_transfer_db(&record, &jobAd);
#else
if (delegation_method) {}
if (elapsed) {}
#endif
}
s->set_crypto_mode(socket_default_crypto);
#ifdef WIN32
bytesRcvd += (float)(signed __int64)(*total_bytes);
#else
bytesRcvd += (*total_bytes);
#endif
bool upload_success = false;
MyString upload_error_buf;
bool upload_try_again = true;
int upload_hold_code = 0;
int upload_hold_subcode = 0;
GetTransferAck(s,upload_success,upload_try_again,upload_hold_code,
upload_hold_subcode,upload_error_buf);
if(!upload_success) {
char const *peer_ip_str = "disconnected socket";
if(s->type() == Stream::reli_sock) {
peer_ip_str = ((Sock *)s)->get_sinful_peer();
}
MyString download_error_buf;
download_error_buf.sprintf("%s failed to receive file(s) from %s",
get_mySubSystem()->getName(),peer_ip_str);
error_buf.sprintf("%s; %s",
upload_error_buf.Value(),
download_error_buf.Value());
dprintf(D_ALWAYS,"DoDownload: %s\n",error_buf.Value());
download_success = false;
SendTransferAck(s,download_success,upload_try_again,upload_hold_code,
upload_hold_subcode,download_error_buf.Value());
Info.error_desc = error_buf.Value();
dprintf( D_FULLDEBUG, "DoDownload: exiting with upload errors\n" );
return_and_resetpriv( -1 );
}
if( !download_success ) {
SendTransferAck(s,download_success,try_again,hold_code,
hold_subcode,error_buf.Value());
dprintf( D_FULLDEBUG, "DoDownload: exiting with download errors\n" );
return_and_resetpriv( -1 );
}
if ( !final_transfer && IsServer() ) {
MyString buf;
int fd;
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,COMMIT_FILENAME);
#if defined(WIN32)
if ((fd = safe_open_wrapper_follow(buf.Value(), O_WRONLY | O_CREAT | O_TRUNC |
_O_BINARY | _O_SEQUENTIAL, 0644)) < 0)
#else
if ((fd = safe_open_wrapper_follow(buf.Value(), O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
#endif
{
dprintf(D_ALWAYS,
"FileTransfer::DoDownload failed to write commit file\n");
return_and_resetpriv( -1 );
}
::close(fd);
CommitFiles();
}
download_success = true;
SendTransferAck(s,download_success,try_again,hold_code,hold_subcode,NULL);
return_and_resetpriv( 0 );
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,281 | FileTransfer::DoObtainAndSendTransferGoAhead(DCTransferQueue &xfer_queue,bool downloading,Stream *s,char const *full_fname,bool &go_ahead_always,bool &try_again,int &hold_code,int &hold_subcode,MyString &error_desc)
{
ClassAd msg;
int go_ahead = GO_AHEAD_UNDEFINED;
int alive_interval = 0;
time_t last_alive = time(NULL);
const int alive_slop = 20;
int min_timeout = 300;
s->decode();
if( !s->get(alive_interval) || !s->end_of_message() ) {
error_desc.sprintf("ObtainAndSendTransferGoAhead: failed on alive_interval before GoAhead");
return false;
}
if( Sock::get_timeout_multiplier() > 0 ) {
min_timeout *= Sock::get_timeout_multiplier();
}
int timeout = alive_interval;
if( timeout < min_timeout ) {
timeout = min_timeout;
msg.Assign(ATTR_TIMEOUT,timeout);
msg.Assign(ATTR_RESULT,go_ahead);
s->encode();
if( !msg.put(*s) || !s->end_of_message() ) {
error_desc.sprintf("Failed to send GoAhead new timeout message.");
}
}
ASSERT( timeout > alive_slop );
timeout -= alive_slop;
if( !xfer_queue.RequestTransferQueueSlot(downloading,full_fname,m_jobid.Value(),timeout,error_desc) )
{
go_ahead = GO_AHEAD_FAILED;
}
while(1) {
if( go_ahead == GO_AHEAD_UNDEFINED ) {
timeout = alive_interval - (time(NULL) - last_alive) - alive_slop;
if( timeout < min_timeout ) timeout = min_timeout;
bool pending = true;
if( xfer_queue.PollForTransferQueueSlot(timeout,pending,error_desc) )
{
if( xfer_queue.GoAheadAlways( downloading ) ) {
go_ahead = GO_AHEAD_ALWAYS;
}
else {
go_ahead = GO_AHEAD_ONCE;
}
}
else if( !pending ) {
go_ahead = GO_AHEAD_FAILED;
}
}
char const *ip = s->peer_ip_str();
char const *go_ahead_desc = "";
if( go_ahead < 0 ) go_ahead_desc = "NO ";
if( go_ahead == GO_AHEAD_UNDEFINED ) go_ahead_desc = "PENDING ";
dprintf( go_ahead < 0 ? D_ALWAYS : D_FULLDEBUG,
"Sending %sGoAhead for %s to %s %s%s.\n",
go_ahead_desc,
ip ? ip : "(null)",
downloading ? "send" : "receive",
full_fname,
(go_ahead == GO_AHEAD_ALWAYS) ? " and all further files":"");
s->encode();
msg.Assign(ATTR_RESULT,go_ahead); // go ahead
if( go_ahead < 0 ) {
msg.Assign(ATTR_TRY_AGAIN,try_again);
msg.Assign(ATTR_HOLD_REASON_CODE,hold_code);
msg.Assign(ATTR_HOLD_REASON_SUBCODE,hold_subcode);
if( error_desc.Length() ) {
msg.Assign(ATTR_HOLD_REASON,error_desc.Value());
}
}
if( !msg.put(*s) || !s->end_of_message() ) {
error_desc.sprintf("Failed to send GoAhead message.");
try_again = true;
return false;
}
last_alive = time(NULL);
if( go_ahead != GO_AHEAD_UNDEFINED ) {
break;
}
}
if( go_ahead == GO_AHEAD_ALWAYS ) {
go_ahead_always = true;
}
return go_ahead > 0;
}
| DoS Exec Code | 0 | FileTransfer::DoObtainAndSendTransferGoAhead(DCTransferQueue &xfer_queue,bool downloading,Stream *s,char const *full_fname,bool &go_ahead_always,bool &try_again,int &hold_code,int &hold_subcode,MyString &error_desc)
{
ClassAd msg;
int go_ahead = GO_AHEAD_UNDEFINED;
int alive_interval = 0;
time_t last_alive = time(NULL);
const int alive_slop = 20;
int min_timeout = 300;
s->decode();
if( !s->get(alive_interval) || !s->end_of_message() ) {
error_desc.sprintf("ObtainAndSendTransferGoAhead: failed on alive_interval before GoAhead");
return false;
}
if( Sock::get_timeout_multiplier() > 0 ) {
min_timeout *= Sock::get_timeout_multiplier();
}
int timeout = alive_interval;
if( timeout < min_timeout ) {
timeout = min_timeout;
msg.Assign(ATTR_TIMEOUT,timeout);
msg.Assign(ATTR_RESULT,go_ahead);
s->encode();
if( !msg.put(*s) || !s->end_of_message() ) {
error_desc.sprintf("Failed to send GoAhead new timeout message.");
}
}
ASSERT( timeout > alive_slop );
timeout -= alive_slop;
if( !xfer_queue.RequestTransferQueueSlot(downloading,full_fname,m_jobid.Value(),timeout,error_desc) )
{
go_ahead = GO_AHEAD_FAILED;
}
while(1) {
if( go_ahead == GO_AHEAD_UNDEFINED ) {
timeout = alive_interval - (time(NULL) - last_alive) - alive_slop;
if( timeout < min_timeout ) timeout = min_timeout;
bool pending = true;
if( xfer_queue.PollForTransferQueueSlot(timeout,pending,error_desc) )
{
if( xfer_queue.GoAheadAlways( downloading ) ) {
go_ahead = GO_AHEAD_ALWAYS;
}
else {
go_ahead = GO_AHEAD_ONCE;
}
}
else if( !pending ) {
go_ahead = GO_AHEAD_FAILED;
}
}
char const *ip = s->peer_ip_str();
char const *go_ahead_desc = "";
if( go_ahead < 0 ) go_ahead_desc = "NO ";
if( go_ahead == GO_AHEAD_UNDEFINED ) go_ahead_desc = "PENDING ";
dprintf( go_ahead < 0 ? D_ALWAYS : D_FULLDEBUG,
"Sending %sGoAhead for %s to %s %s%s.\n",
go_ahead_desc,
ip ? ip : "(null)",
downloading ? "send" : "receive",
full_fname,
(go_ahead == GO_AHEAD_ALWAYS) ? " and all further files":"");
s->encode();
msg.Assign(ATTR_RESULT,go_ahead); // go ahead
if( go_ahead < 0 ) {
msg.Assign(ATTR_TRY_AGAIN,try_again);
msg.Assign(ATTR_HOLD_REASON_CODE,hold_code);
msg.Assign(ATTR_HOLD_REASON_SUBCODE,hold_subcode);
if( error_desc.Length() ) {
msg.Assign(ATTR_HOLD_REASON,error_desc.Value());
}
}
if( !msg.put(*s) || !s->end_of_message() ) {
error_desc.sprintf("Failed to send GoAhead message.");
try_again = true;
return false;
}
last_alive = time(NULL);
if( go_ahead != GO_AHEAD_UNDEFINED ) {
break;
}
}
if( go_ahead == GO_AHEAD_ALWAYS ) {
go_ahead_always = true;
}
return go_ahead > 0;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,282 | FileTransfer::Download(ReliSock *s, bool blocking)
{
dprintf(D_FULLDEBUG,"entering FileTransfer::Download\n");
if (ActiveTransferTid >= 0) {
EXCEPT("FileTransfer::Download called during active transfer!\n");
}
Info.duration = 0;
Info.type = DownloadFilesType;
Info.success = true;
Info.in_progress = true;
TransferStart = time(NULL);
if (blocking) {
int status = DoDownload( &Info.bytes, (ReliSock *) s );
Info.duration = time(NULL)-TransferStart;
Info.success = ( status >= 0 );
Info.in_progress = false;
return Info.success;
} else {
ASSERT( daemonCore );
if (pipe(TransferPipe) < 0) {
dprintf(D_ALWAYS, "pipe failed with errno %d in "
"FileTransfer::Upload\n", errno);
return FALSE;
}
download_info *info = (download_info *)malloc(sizeof(download_info));
info->myobj = this;
ActiveTransferTid = daemonCore->
Create_Thread((ThreadStartFunc)&FileTransfer::DownloadThread,
(void *)info, s, ReaperId);
if (ActiveTransferTid == FALSE) {
dprintf(D_ALWAYS,
"Failed to create FileTransfer DownloadThread!\n");
ActiveTransferTid = -1;
free(info);
return FALSE;
}
TransThreadTable->insert(ActiveTransferTid, this);
}
return 1;
}
| DoS Exec Code | 0 | FileTransfer::Download(ReliSock *s, bool blocking)
{
dprintf(D_FULLDEBUG,"entering FileTransfer::Download\n");
if (ActiveTransferTid >= 0) {
EXCEPT("FileTransfer::Download called during active transfer!\n");
}
Info.duration = 0;
Info.type = DownloadFilesType;
Info.success = true;
Info.in_progress = true;
TransferStart = time(NULL);
if (blocking) {
int status = DoDownload( &Info.bytes, (ReliSock *) s );
Info.duration = time(NULL)-TransferStart;
Info.success = ( status >= 0 );
Info.in_progress = false;
return Info.success;
} else {
ASSERT( daemonCore );
if (pipe(TransferPipe) < 0) {
dprintf(D_ALWAYS, "pipe failed with errno %d in "
"FileTransfer::Upload\n", errno);
return FALSE;
}
download_info *info = (download_info *)malloc(sizeof(download_info));
info->myobj = this;
ActiveTransferTid = daemonCore->
Create_Thread((ThreadStartFunc)&FileTransfer::DownloadThread,
(void *)info, s, ReaperId);
if (ActiveTransferTid == FALSE) {
dprintf(D_ALWAYS,
"Failed to create FileTransfer DownloadThread!\n");
ActiveTransferTid = -1;
free(info);
return FALSE;
}
TransThreadTable->insert(ActiveTransferTid, this);
}
return 1;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,283 | FileTransfer::DownloadFiles(bool blocking)
{
int ret_value;
ReliSock sock;
ReliSock *sock_to_use;
dprintf(D_FULLDEBUG,"entering FileTransfer::DownloadFiles\n");
if (ActiveTransferTid >= 0) {
EXCEPT("FileTransfer::DownloadFiles called during active transfer!\n");
}
if ( Iwd == NULL ) {
EXCEPT("FileTransfer: Init() never called");
}
if (!simple_init) {
if ( IsServer() ) {
EXCEPT("FileTransfer: DownloadFiles called on server side");
}
sock.timeout(clientSockTimeout);
Daemon d( DT_ANY, TransSock );
if ( !d.connectSock(&sock,0) ) {
dprintf( D_ALWAYS, "FileTransfer: Unable to connect to server "
"%s\n", TransSock );
return FALSE;
}
d.startCommand(FILETRANS_UPLOAD, &sock, 0, NULL, NULL, false, m_sec_session_id);
sock.encode();
if ( !sock.put_secret(TransKey) ||
!sock.end_of_message() ) {
return 0;
}
sock_to_use = &sock;
} else {
ASSERT(simple_sock);
sock_to_use = simple_sock;
}
ret_value = Download(sock_to_use,blocking);
if ( !simple_init && blocking && ret_value == 1 && upload_changed_files ) {
time(&last_download_time);
BuildFileCatalog();
sleep(1);
}
return ret_value;
}
| DoS Exec Code | 0 | FileTransfer::DownloadFiles(bool blocking)
{
int ret_value;
ReliSock sock;
ReliSock *sock_to_use;
dprintf(D_FULLDEBUG,"entering FileTransfer::DownloadFiles\n");
if (ActiveTransferTid >= 0) {
EXCEPT("FileTransfer::DownloadFiles called during active transfer!\n");
}
if ( Iwd == NULL ) {
EXCEPT("FileTransfer: Init() never called");
}
if (!simple_init) {
if ( IsServer() ) {
EXCEPT("FileTransfer: DownloadFiles called on server side");
}
sock.timeout(clientSockTimeout);
Daemon d( DT_ANY, TransSock );
if ( !d.connectSock(&sock,0) ) {
dprintf( D_ALWAYS, "FileTransfer: Unable to connect to server "
"%s\n", TransSock );
return FALSE;
}
d.startCommand(FILETRANS_UPLOAD, &sock, 0, NULL, NULL, false, m_sec_session_id);
sock.encode();
if ( !sock.put_secret(TransKey) ||
!sock.end_of_message() ) {
return 0;
}
sock_to_use = &sock;
} else {
ASSERT(simple_sock);
sock_to_use = simple_sock;
}
ret_value = Download(sock_to_use,blocking);
if ( !simple_init && blocking && ret_value == 1 && upload_changed_files ) {
time(&last_download_time);
BuildFileCatalog();
sleep(1);
}
return ret_value;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,284 | FileTransfer::ExitDoUpload(filesize_t *total_bytes, ReliSock *s, priv_state saved_priv, bool socket_default_crypto, bool upload_success, bool do_upload_ack, bool do_download_ack, bool try_again, int hold_code, int hold_subcode, char const *upload_error_desc,int DoUpload_exit_line)
{
int rc = upload_success ? 0 : -1;
bool download_success = false;
MyString error_buf;
MyString download_error_buf;
char const *error_desc = NULL;
dprintf(D_FULLDEBUG,"DoUpload: exiting at %d\n",DoUpload_exit_line);
if( saved_priv != PRIV_UNKNOWN ) {
_set_priv(saved_priv,__FILE__,DoUpload_exit_line,1);
}
#ifdef WIN32
bytesSent += (float)(signed __int64)*total_bytes;
#else
bytesSent += *total_bytes;
#endif
if(do_upload_ack) {
if(!PeerDoesTransferAck && !upload_success) {
}
else {
s->snd_int(0,TRUE);
MyString error_desc_to_send;
if(!upload_success) {
error_desc_to_send.sprintf("%s at %s failed to send file(s) to %s",
get_mySubSystem()->getName(),
s->my_ip_str(),
s->get_sinful_peer());
if(upload_error_desc) {
error_desc_to_send.sprintf_cat(": %s",upload_error_desc);
}
}
SendTransferAck(s,upload_success,try_again,hold_code,hold_subcode,
error_desc_to_send.Value());
}
}
if(do_download_ack) {
GetTransferAck(s,download_success,try_again,hold_code,hold_subcode,
download_error_buf);
if(!download_success) {
rc = -1;
}
}
if(rc != 0) {
char const *receiver_ip_str = s->get_sinful_peer();
if(!receiver_ip_str) {
receiver_ip_str = "disconnected socket";
}
error_buf.sprintf("%s at %s failed to send file(s) to %s",
get_mySubSystem()->getName(),
s->my_ip_str(),receiver_ip_str);
if(upload_error_desc) {
error_buf.sprintf_cat(": %s",upload_error_desc);
}
if(!download_error_buf.IsEmpty()) {
error_buf.sprintf_cat("; %s",download_error_buf.Value());
}
error_desc = error_buf.Value();
if(!error_desc) {
error_desc = "";
}
if(try_again) {
dprintf(D_ALWAYS,"DoUpload: %s\n",error_desc);
}
else {
dprintf(D_ALWAYS,"DoUpload: (Condor error code %d, subcode %d) %s\n",hold_code,hold_subcode,error_desc);
}
}
s->set_crypto_mode(socket_default_crypto);
Info.success = rc == 0;
Info.try_again = try_again;
Info.hold_code = hold_code;
Info.hold_subcode = hold_subcode;
Info.error_desc = error_desc;
return rc;
}
| DoS Exec Code | 0 | FileTransfer::ExitDoUpload(filesize_t *total_bytes, ReliSock *s, priv_state saved_priv, bool socket_default_crypto, bool upload_success, bool do_upload_ack, bool do_download_ack, bool try_again, int hold_code, int hold_subcode, char const *upload_error_desc,int DoUpload_exit_line)
{
int rc = upload_success ? 0 : -1;
bool download_success = false;
MyString error_buf;
MyString download_error_buf;
char const *error_desc = NULL;
dprintf(D_FULLDEBUG,"DoUpload: exiting at %d\n",DoUpload_exit_line);
if( saved_priv != PRIV_UNKNOWN ) {
_set_priv(saved_priv,__FILE__,DoUpload_exit_line,1);
}
#ifdef WIN32
bytesSent += (float)(signed __int64)*total_bytes;
#else
bytesSent += *total_bytes;
#endif
if(do_upload_ack) {
if(!PeerDoesTransferAck && !upload_success) {
}
else {
s->snd_int(0,TRUE);
MyString error_desc_to_send;
if(!upload_success) {
error_desc_to_send.sprintf("%s at %s failed to send file(s) to %s",
get_mySubSystem()->getName(),
s->my_ip_str(),
s->get_sinful_peer());
if(upload_error_desc) {
error_desc_to_send.sprintf_cat(": %s",upload_error_desc);
}
}
SendTransferAck(s,upload_success,try_again,hold_code,hold_subcode,
error_desc_to_send.Value());
}
}
if(do_download_ack) {
GetTransferAck(s,download_success,try_again,hold_code,hold_subcode,
download_error_buf);
if(!download_success) {
rc = -1;
}
}
if(rc != 0) {
char const *receiver_ip_str = s->get_sinful_peer();
if(!receiver_ip_str) {
receiver_ip_str = "disconnected socket";
}
error_buf.sprintf("%s at %s failed to send file(s) to %s",
get_mySubSystem()->getName(),
s->my_ip_str(),receiver_ip_str);
if(upload_error_desc) {
error_buf.sprintf_cat(": %s",upload_error_desc);
}
if(!download_error_buf.IsEmpty()) {
error_buf.sprintf_cat("; %s",download_error_buf.Value());
}
error_desc = error_buf.Value();
if(!error_desc) {
error_desc = "";
}
if(try_again) {
dprintf(D_ALWAYS,"DoUpload: %s\n",error_desc);
}
else {
dprintf(D_ALWAYS,"DoUpload: (Condor error code %d, subcode %d) %s\n",hold_code,hold_subcode,error_desc);
}
}
s->set_crypto_mode(socket_default_crypto);
Info.success = rc == 0;
Info.try_again = try_again;
Info.hold_code = hold_code;
Info.hold_subcode = hold_subcode;
Info.error_desc = error_desc;
return rc;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,285 | FileTransfer::ExpandFileTransferList( StringList *input_list, FileTransferList &expanded_list )
{
bool rc = true;
if( !input_list ) {
return true;
}
if (X509UserProxy && input_list->contains(X509UserProxy)) {
if( !ExpandFileTransferList( X509UserProxy, "", Iwd, -1, expanded_list ) ) {
rc = false;
}
}
input_list->rewind();
char const *path;
while ( (path=input_list->next()) != NULL ) {
if(!X509UserProxy || (X509UserProxy && strcmp(path, X509UserProxy) != 0)) {
if( !ExpandFileTransferList( path, "", Iwd, -1, expanded_list ) ) {
rc = false;
}
}
}
return rc;
}
| DoS Exec Code | 0 | FileTransfer::ExpandFileTransferList( StringList *input_list, FileTransferList &expanded_list )
{
bool rc = true;
if( !input_list ) {
return true;
}
if (X509UserProxy && input_list->contains(X509UserProxy)) {
if( !ExpandFileTransferList( X509UserProxy, "", Iwd, -1, expanded_list ) ) {
rc = false;
}
}
input_list->rewind();
char const *path;
while ( (path=input_list->next()) != NULL ) {
if(!X509UserProxy || (X509UserProxy && strcmp(path, X509UserProxy) != 0)) {
if( !ExpandFileTransferList( path, "", Iwd, -1, expanded_list ) ) {
rc = false;
}
}
}
return rc;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,286 | FileTransfer::ExpandFileTransferList( char const *src_path, char const *dest_dir, char const *iwd, int max_depth, FileTransferList &expanded_list )
{
ASSERT( src_path );
ASSERT( dest_dir );
ASSERT( iwd );
expanded_list.push_back( FileTransferItem() );
FileTransferItem &file_xfer_item = expanded_list.back();
file_xfer_item.src_name = src_path;
file_xfer_item.dest_dir = dest_dir;
if( IsUrl(src_path) ) {
return true;
}
std::string full_src_path;
if( is_relative_to_cwd( src_path ) ) {
full_src_path = iwd;
if( full_src_path.length() > 0 ) {
full_src_path += DIR_DELIM_CHAR;
}
}
full_src_path += src_path;
StatInfo st( full_src_path.c_str() );
if( st.Error() != 0 ) {
return false;
}
#ifndef WIN32
file_xfer_item.file_mode = (condor_mode_t)st.GetMode();
#endif
size_t srclen = file_xfer_item.src_name.length();
bool trailing_slash = srclen > 0 && src_path[srclen-1] == DIR_DELIM_CHAR;
file_xfer_item.is_symlink = st.IsSymlink();
file_xfer_item.is_directory = st.IsDirectory();
if( !file_xfer_item.is_directory ) {
return true;
}
if( !trailing_slash && file_xfer_item.is_symlink ) {
return true;
}
if( max_depth == 0 ) {
return true; // this is not considered an error
}
if( max_depth > 0 ) {
max_depth--;
}
std::string dest_dir_buf;
if( trailing_slash ) {
expanded_list.pop_back();
}
else {
dest_dir_buf = dest_dir;
if( dest_dir_buf.length() > 0 ) {
dest_dir_buf += DIR_DELIM_CHAR;
}
dest_dir_buf += condor_basename(src_path);
dest_dir = dest_dir_buf.c_str();
}
Directory dir( &st );
dir.Rewind();
bool rc = true;
char const *file_in_dir;
while( (file_in_dir=dir.Next()) != NULL ) {
std::string file_full_path = src_path;
if( !trailing_slash ) {
file_full_path += DIR_DELIM_CHAR;
}
file_full_path += file_in_dir;
if( !ExpandFileTransferList( file_full_path.c_str(), dest_dir, iwd, max_depth, expanded_list ) ) {
rc = false;
}
}
return rc;
}
| DoS Exec Code | 0 | FileTransfer::ExpandFileTransferList( char const *src_path, char const *dest_dir, char const *iwd, int max_depth, FileTransferList &expanded_list )
{
ASSERT( src_path );
ASSERT( dest_dir );
ASSERT( iwd );
expanded_list.push_back( FileTransferItem() );
FileTransferItem &file_xfer_item = expanded_list.back();
file_xfer_item.src_name = src_path;
file_xfer_item.dest_dir = dest_dir;
if( IsUrl(src_path) ) {
return true;
}
std::string full_src_path;
if( is_relative_to_cwd( src_path ) ) {
full_src_path = iwd;
if( full_src_path.length() > 0 ) {
full_src_path += DIR_DELIM_CHAR;
}
}
full_src_path += src_path;
StatInfo st( full_src_path.c_str() );
if( st.Error() != 0 ) {
return false;
}
#ifndef WIN32
file_xfer_item.file_mode = (condor_mode_t)st.GetMode();
#endif
size_t srclen = file_xfer_item.src_name.length();
bool trailing_slash = srclen > 0 && src_path[srclen-1] == DIR_DELIM_CHAR;
file_xfer_item.is_symlink = st.IsSymlink();
file_xfer_item.is_directory = st.IsDirectory();
if( !file_xfer_item.is_directory ) {
return true;
}
if( !trailing_slash && file_xfer_item.is_symlink ) {
return true;
}
if( max_depth == 0 ) {
return true; // this is not considered an error
}
if( max_depth > 0 ) {
max_depth--;
}
std::string dest_dir_buf;
if( trailing_slash ) {
expanded_list.pop_back();
}
else {
dest_dir_buf = dest_dir;
if( dest_dir_buf.length() > 0 ) {
dest_dir_buf += DIR_DELIM_CHAR;
}
dest_dir_buf += condor_basename(src_path);
dest_dir = dest_dir_buf.c_str();
}
Directory dir( &st );
dir.Rewind();
bool rc = true;
char const *file_in_dir;
while( (file_in_dir=dir.Next()) != NULL ) {
std::string file_full_path = src_path;
if( !trailing_slash ) {
file_full_path += DIR_DELIM_CHAR;
}
file_full_path += file_in_dir;
if( !ExpandFileTransferList( file_full_path.c_str(), dest_dir, iwd, max_depth, expanded_list ) ) {
rc = false;
}
}
return rc;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,287 | FileTransfer::FileTransfer()
{
TransferFilePermissions = false;
DelegateX509Credentials = false;
PeerDoesTransferAck = false;
PeerDoesGoAhead = false;
PeerUnderstandsMkdir = false;
TransferUserLog = false;
Iwd = NULL;
ExceptionFiles = NULL;
InputFiles = NULL;
OutputFiles = NULL;
EncryptInputFiles = NULL;
EncryptOutputFiles = NULL;
DontEncryptInputFiles = NULL;
DontEncryptOutputFiles = NULL;
IntermediateFiles = NULL;
SpooledIntermediateFiles = NULL;
FilesToSend = NULL;
EncryptFiles = NULL;
DontEncryptFiles = NULL;
OutputDestination = NULL;
ExecFile = NULL;
UserLogFile = NULL;
X509UserProxy = NULL;
TransSock = NULL;
TransKey = NULL;
SpoolSpace = NULL;
TmpSpoolSpace = NULL;
user_supplied_key = FALSE;
upload_changed_files = false;
last_download_catalog = NULL;
last_download_time = 0;
ActiveTransferTid = -1;
TransferStart = 0;
ClientCallback = 0;
ClientCallbackClass = NULL;
TransferPipe[0] = TransferPipe[1] = -1;
bytesSent = 0.0;
bytesRcvd = 0.0;
m_final_transfer_flag = FALSE;
#ifdef WIN32
perm_obj = NULL;
#endif
desired_priv_state = PRIV_UNKNOWN;
want_priv_change = false;
did_init = false;
clientSockTimeout = 30;
simple_init = true;
simple_sock = NULL;
m_use_file_catalog = true;
m_sec_session_id = NULL;
I_support_filetransfer_plugins = false;
plugin_table = NULL;
}
| DoS Exec Code | 0 | FileTransfer::FileTransfer()
{
TransferFilePermissions = false;
DelegateX509Credentials = false;
PeerDoesTransferAck = false;
PeerDoesGoAhead = false;
PeerUnderstandsMkdir = false;
TransferUserLog = false;
Iwd = NULL;
ExceptionFiles = NULL;
InputFiles = NULL;
OutputFiles = NULL;
EncryptInputFiles = NULL;
EncryptOutputFiles = NULL;
DontEncryptInputFiles = NULL;
DontEncryptOutputFiles = NULL;
IntermediateFiles = NULL;
SpooledIntermediateFiles = NULL;
FilesToSend = NULL;
EncryptFiles = NULL;
DontEncryptFiles = NULL;
OutputDestination = NULL;
ExecFile = NULL;
UserLogFile = NULL;
X509UserProxy = NULL;
TransSock = NULL;
TransKey = NULL;
SpoolSpace = NULL;
TmpSpoolSpace = NULL;
user_supplied_key = FALSE;
upload_changed_files = false;
last_download_catalog = NULL;
last_download_time = 0;
ActiveTransferTid = -1;
TransferStart = 0;
ClientCallback = 0;
ClientCallbackClass = NULL;
TransferPipe[0] = TransferPipe[1] = -1;
bytesSent = 0.0;
bytesRcvd = 0.0;
m_final_transfer_flag = FALSE;
#ifdef WIN32
perm_obj = NULL;
#endif
desired_priv_state = PRIV_UNKNOWN;
want_priv_change = false;
did_init = false;
clientSockTimeout = 30;
simple_init = true;
simple_sock = NULL;
m_use_file_catalog = true;
m_sec_session_id = NULL;
I_support_filetransfer_plugins = false;
plugin_table = NULL;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,288 | FileTransferItem():
is_directory(false),
is_symlink(false),
file_mode(NULL_FILE_PERMISSIONS) {}
| DoS Exec Code | 0 | FileTransferItem():
is_directory(false),
is_symlink(false),
file_mode(NULL_FILE_PERMISSIONS) {}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,289 | GetDelegatedProxyRenewalTime(time_t expiration_time)
{
if( expiration_time == 0 ) {
return 0;
}
if ( !param_boolean( "DELEGATE_JOB_GSI_CREDENTIALS", true ) ) {
return 0;
}
time_t now = time(NULL);
time_t lifetime = expiration_time - now;
double lifetime_frac = param_double( "DELEGATE_JOB_GSI_CREDENTIALS_RENEWAL", 0.25,0,1);
return now + (time_t)floor(lifetime*lifetime_frac);
}
| DoS Exec Code | 0 | GetDelegatedProxyRenewalTime(time_t expiration_time)
{
if( expiration_time == 0 ) {
return 0;
}
if ( !param_boolean( "DELEGATE_JOB_GSI_CREDENTIALS", true ) ) {
return 0;
}
time_t now = time(NULL);
time_t lifetime = expiration_time - now;
double lifetime_frac = param_double( "DELEGATE_JOB_GSI_CREDENTIALS_RENEWAL", 0.25,0,1);
return now + (time_t)floor(lifetime*lifetime_frac);
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,290 | GetDelegatedProxyRenewalTime(ClassAd *jobAd)
{
GetDelegatedProxyRenewalTime(GetDesiredDelegatedJobCredentialExpiration(jobAd));
}
| DoS Exec Code | 0 | GetDelegatedProxyRenewalTime(ClassAd *jobAd)
{
GetDelegatedProxyRenewalTime(GetDesiredDelegatedJobCredentialExpiration(jobAd));
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,291 | FileTransfer::GetTransferAck(Stream *s,bool &success,bool &try_again,int &hold_code,int &hold_subcode,MyString &error_desc)
{
if(!PeerDoesTransferAck) {
success = true;
return;
}
s->decode();
ClassAd ad;
if(!ad.initFromStream(*s) || !s->end_of_message()) {
char const *ip = NULL;
if(s->type() == Sock::reli_sock) {
ip = ((ReliSock *)s)->get_sinful_peer();
}
dprintf(D_FULLDEBUG,"Failed to receive download acknowledgment from %s.\n",
ip ? ip : "(disconnected socket)");
success = false;
try_again = true; // could just be a transient network problem
return;
}
int result = -1;
if(!ad.LookupInteger(ATTR_RESULT,result)) {
MyString ad_str;
ad.sPrint(ad_str);
dprintf(D_ALWAYS,"Download acknowledgment missing attribute: %s. Full classad: [\n%s]\n",ATTR_RESULT,ad_str.Value());
success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_InvalidTransferAck;
hold_subcode = 0;
error_desc.sprintf("Download acknowledgment missing attribute: %s",ATTR_RESULT);
return;
}
if(result == 0) {
success = true;
try_again = false;
}
else if(result > 0) {
success = false;
try_again = true;
}
else {
success = false;
try_again = false;
}
if(!ad.LookupInteger(ATTR_HOLD_REASON_CODE,hold_code)) {
hold_code = 0;
}
if(!ad.LookupInteger(ATTR_HOLD_REASON_SUBCODE,hold_subcode)) {
hold_subcode = 0;
}
char *hold_reason_buf = NULL;
if(ad.LookupString(ATTR_HOLD_REASON,&hold_reason_buf)) {
error_desc = hold_reason_buf;
free(hold_reason_buf);
}
}
| DoS Exec Code | 0 | FileTransfer::GetTransferAck(Stream *s,bool &success,bool &try_again,int &hold_code,int &hold_subcode,MyString &error_desc)
{
if(!PeerDoesTransferAck) {
success = true;
return;
}
s->decode();
ClassAd ad;
if(!ad.initFromStream(*s) || !s->end_of_message()) {
char const *ip = NULL;
if(s->type() == Sock::reli_sock) {
ip = ((ReliSock *)s)->get_sinful_peer();
}
dprintf(D_FULLDEBUG,"Failed to receive download acknowledgment from %s.\n",
ip ? ip : "(disconnected socket)");
success = false;
try_again = true; // could just be a transient network problem
return;
}
int result = -1;
if(!ad.LookupInteger(ATTR_RESULT,result)) {
MyString ad_str;
ad.sPrint(ad_str);
dprintf(D_ALWAYS,"Download acknowledgment missing attribute: %s. Full classad: [\n%s]\n",ATTR_RESULT,ad_str.Value());
success = false;
try_again = false;
hold_code = CONDOR_HOLD_CODE_InvalidTransferAck;
hold_subcode = 0;
error_desc.sprintf("Download acknowledgment missing attribute: %s",ATTR_RESULT);
return;
}
if(result == 0) {
success = true;
try_again = false;
}
else if(result > 0) {
success = false;
try_again = true;
}
else {
success = false;
try_again = false;
}
if(!ad.LookupInteger(ATTR_HOLD_REASON_CODE,hold_code)) {
hold_code = 0;
}
if(!ad.LookupInteger(ATTR_HOLD_REASON_SUBCODE,hold_subcode)) {
hold_subcode = 0;
}
char *hold_reason_buf = NULL;
if(ad.LookupString(ATTR_HOLD_REASON,&hold_reason_buf)) {
error_desc = hold_reason_buf;
free(hold_reason_buf);
}
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,292 | FileTransfer::HandleCommands(Service *, int command, Stream *s)
{
FileTransfer *transobject;
char *transkey = NULL;
dprintf(D_FULLDEBUG,"entering FileTransfer::HandleCommands\n");
if ( s->type() != Stream::reli_sock ) {
return 0;
}
ReliSock *sock = (ReliSock *) s;
sock->timeout(0);
if (!sock->get_secret(transkey) ||
!sock->end_of_message() ) {
dprintf(D_FULLDEBUG,
"FileTransfer::HandleCommands failed to read transkey\n");
return 0;
}
dprintf(D_FULLDEBUG,
"FileTransfer::HandleCommands read transkey=%s\n",transkey);
MyString key(transkey);
free(transkey);
if ( (TranskeyTable == NULL) ||
(TranskeyTable->lookup(key,transobject) < 0) ) {
sock->snd_int(0,1); // sends a "0" then an end_of_record
dprintf(D_FULLDEBUG,"transkey is invalid!\n");
sleep(5);
return FALSE;
}
switch (command) {
case FILETRANS_UPLOAD:
{
const char *currFile;
transobject->CommitFiles();
Directory spool_space( transobject->SpoolSpace,
transobject->getDesiredPrivState() );
while ( (currFile=spool_space.Next()) ) {
if (transobject->UserLogFile &&
!file_strcmp(transobject->UserLogFile,currFile))
{
continue;
} else {
const char *filename = spool_space.GetFullPath();
if ( !transobject->InputFiles->file_contains(filename) &&
!transobject->InputFiles->file_contains(condor_basename(filename)) ) {
transobject->InputFiles->append(filename);
}
}
}
transobject->FilesToSend = transobject->InputFiles;
transobject->EncryptFiles = transobject->EncryptInputFiles;
transobject->DontEncryptFiles = transobject->DontEncryptInputFiles;
transobject->Upload(sock,true); // blocking = true for now...
}
break;
case FILETRANS_DOWNLOAD:
transobject->Download(sock,true); // blocking = true for now...
break;
default:
dprintf(D_ALWAYS,
"FileTransfer::HandleCommands: unrecognized command %d\n",
command);
return 0;
break;
}
return 1;
}
| DoS Exec Code | 0 | FileTransfer::HandleCommands(Service *, int command, Stream *s)
{
FileTransfer *transobject;
char *transkey = NULL;
dprintf(D_FULLDEBUG,"entering FileTransfer::HandleCommands\n");
if ( s->type() != Stream::reli_sock ) {
return 0;
}
ReliSock *sock = (ReliSock *) s;
sock->timeout(0);
if (!sock->get_secret(transkey) ||
!sock->end_of_message() ) {
dprintf(D_FULLDEBUG,
"FileTransfer::HandleCommands failed to read transkey\n");
return 0;
}
dprintf(D_FULLDEBUG,
"FileTransfer::HandleCommands read transkey=%s\n",transkey);
MyString key(transkey);
free(transkey);
if ( (TranskeyTable == NULL) ||
(TranskeyTable->lookup(key,transobject) < 0) ) {
sock->snd_int(0,1); // sends a "0" then an end_of_record
dprintf(D_FULLDEBUG,"transkey is invalid!\n");
sleep(5);
return FALSE;
}
switch (command) {
case FILETRANS_UPLOAD:
{
const char *currFile;
transobject->CommitFiles();
Directory spool_space( transobject->SpoolSpace,
transobject->getDesiredPrivState() );
while ( (currFile=spool_space.Next()) ) {
if (transobject->UserLogFile &&
!file_strcmp(transobject->UserLogFile,currFile))
{
continue;
} else {
const char *filename = spool_space.GetFullPath();
if ( !transobject->InputFiles->file_contains(filename) &&
!transobject->InputFiles->file_contains(condor_basename(filename)) ) {
transobject->InputFiles->append(filename);
}
}
}
transobject->FilesToSend = transobject->InputFiles;
transobject->EncryptFiles = transobject->EncryptInputFiles;
transobject->DontEncryptFiles = transobject->DontEncryptInputFiles;
transobject->Upload(sock,true); // blocking = true for now...
}
break;
case FILETRANS_DOWNLOAD:
transobject->Download(sock,true); // blocking = true for now...
break;
default:
dprintf(D_ALWAYS,
"FileTransfer::HandleCommands: unrecognized command %d\n",
command);
return 0;
break;
}
return 1;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,293 | FileTransfer::InitDownloadFilenameRemaps(ClassAd *Ad) {
char *remap_fname = NULL;
dprintf(D_FULLDEBUG,"Entering FileTransfer::InitDownloadFilenameRemaps\n");
download_filename_remaps = "";
if(!Ad) return 1;
if (Ad->LookupString(ATTR_TRANSFER_OUTPUT_REMAPS,&remap_fname)) {
AddDownloadFilenameRemaps(remap_fname);
free(remap_fname);
remap_fname = NULL;
}
if(!download_filename_remaps.IsEmpty()) {
dprintf(D_FULLDEBUG, "FileTransfer: output file remaps: %s\n",download_filename_remaps.Value());
}
return 1;
}
| DoS Exec Code | 0 | FileTransfer::InitDownloadFilenameRemaps(ClassAd *Ad) {
char *remap_fname = NULL;
dprintf(D_FULLDEBUG,"Entering FileTransfer::InitDownloadFilenameRemaps\n");
download_filename_remaps = "";
if(!Ad) return 1;
if (Ad->LookupString(ATTR_TRANSFER_OUTPUT_REMAPS,&remap_fname)) {
AddDownloadFilenameRemaps(remap_fname);
free(remap_fname);
remap_fname = NULL;
}
if(!download_filename_remaps.IsEmpty()) {
dprintf(D_FULLDEBUG, "FileTransfer: output file remaps: %s\n",download_filename_remaps.Value());
}
return 1;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,294 | int FileTransfer::InitializePlugins(CondorError &e) {
if (!param_boolean("ENABLE_URL_TRANSFERS", true)) {
I_support_filetransfer_plugins = false;
return 0;
}
char* plugin_list_string = param("FILETRANSFER_PLUGINS");
if (!plugin_list_string) {
I_support_filetransfer_plugins = false;
return 0;
}
plugin_table = new PluginHashTable(7, compute_filename_hash);
StringList plugin_list (plugin_list_string);
plugin_list.rewind();
char *p;
while ((p = plugin_list.next())) {
MyString methods = DeterminePluginMethods(e, p);
if (!methods.IsEmpty()) {
I_support_filetransfer_plugins = true;
InsertPluginMappings(methods, p);
} else {
dprintf(D_ALWAYS, "FILETRANSFER: failed to add plugin \"%s\" because: %s\n", p, e.getFullText());
}
}
free(plugin_list_string);
return 0;
}
| DoS Exec Code | 0 | int FileTransfer::InitializePlugins(CondorError &e) {
if (!param_boolean("ENABLE_URL_TRANSFERS", true)) {
I_support_filetransfer_plugins = false;
return 0;
}
char* plugin_list_string = param("FILETRANSFER_PLUGINS");
if (!plugin_list_string) {
I_support_filetransfer_plugins = false;
return 0;
}
plugin_table = new PluginHashTable(7, compute_filename_hash);
StringList plugin_list (plugin_list_string);
plugin_list.rewind();
char *p;
while ((p = plugin_list.next())) {
MyString methods = DeterminePluginMethods(e, p);
if (!methods.IsEmpty()) {
I_support_filetransfer_plugins = true;
InsertPluginMappings(methods, p);
} else {
dprintf(D_ALWAYS, "FILETRANSFER: failed to add plugin \"%s\" because: %s\n", p, e.getFullText());
}
}
free(plugin_list_string);
return 0;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,295 | FileTransfer::InsertPluginMappings(MyString methods, MyString p)
{
StringList method_list(methods.Value());
char* m;
method_list.rewind();
while((m = method_list.next())) {
dprintf(D_FULLDEBUG, "FILETRANSFER: protocol \"%s\" handled by \"%s\"\n", m, p.Value());
plugin_table->insert(m, p);
}
}
| DoS Exec Code | 0 | FileTransfer::InsertPluginMappings(MyString methods, MyString p)
{
StringList method_list(methods.Value());
char* m;
method_list.rewind();
while((m = method_list.next())) {
dprintf(D_FULLDEBUG, "FILETRANSFER: protocol \"%s\" handled by \"%s\"\n", m, p.Value());
plugin_table->insert(m, p);
}
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,296 | int FileTransfer::InvokeFileTransferPlugin(CondorError &e, const char* source, const char* dest, const char* proxy_filename) {
if (plugin_table == NULL) {
dprintf(D_FULLDEBUG, "FILETRANSFER: No plugin table defined! (request was %s)\n", source);
e.pushf("FILETRANSFER", 1, "No plugin table defined (request was %s)", source);
return GET_FILE_PLUGIN_FAILED;
}
char *URL = NULL;
if(IsUrl(dest)) {
URL = const_cast<char*>(dest);
dprintf(D_FULLDEBUG, "FILETRANSFER: using destination to determine plugin type: %s\n", dest);
} else {
URL = const_cast<char*>(source);
dprintf(D_FULLDEBUG, "FILETRANSFER: using source to determine plugin type: %s\n", source);
}
const char* colon = strchr(URL, ':');
if (!colon) {
e.pushf("FILETRANSFER", 1, "Specified URL does not contain a ':' (%s)", URL);
return GET_FILE_PLUGIN_FAILED;
}
char* method = (char*) malloc(1 + (colon-URL));
strncpy(method, URL, (colon-URL));
method[(colon-URL)] = '\0';
MyString plugin;
if (plugin_table->lookup((MyString)method, plugin)) {
e.pushf("FILETRANSFER", 1, "FILETRANSFER: plugin for type %s not found!", method);
dprintf (D_FULLDEBUG, "FILETRANSFER: plugin for type %s not found!\n", method);
free(method);
return GET_FILE_PLUGIN_FAILED;
}
/*
if (absolute_path_check() ) {
dprintf(D_ALWAYS, "FILETRANSFER: NOT invoking malformed plugin named \"%s\"\n", plugin.Value());
FAIL();
}
*/
Env plugin_env;
plugin_env.Import();
if (proxy_filename && *proxy_filename) {
plugin_env.SetEnv("X509_USER_PROXY",proxy_filename);
dprintf(D_FULLDEBUG, "FILETRANSFER: setting X509_USER_PROXY env to %s\n", proxy_filename);
}
ArgList plugin_args;
plugin_args.AppendArg(plugin.Value());
plugin_args.AppendArg(source);
plugin_args.AppendArg(dest);
dprintf(D_FULLDEBUG, "FILETRANSFER: invoking: %s %s %s\n", plugin.Value(), source, dest);
FILE* plugin_pipe = my_popen(plugin_args, "r", FALSE, &plugin_env);
int plugin_status = my_pclose(plugin_pipe);
dprintf (D_ALWAYS, "FILETRANSFER: plugin returned %i\n", plugin_status);
free(method);
if (plugin_status != 0) {
e.pushf("FILETRANSFER", 1, "non-zero exit(%i) from %s\n", plugin_status, plugin.Value());
return GET_FILE_PLUGIN_FAILED;
}
return 0;
}
| DoS Exec Code | 0 | int FileTransfer::InvokeFileTransferPlugin(CondorError &e, const char* source, const char* dest, const char* proxy_filename) {
if (plugin_table == NULL) {
dprintf(D_FULLDEBUG, "FILETRANSFER: No plugin table defined! (request was %s)\n", source);
e.pushf("FILETRANSFER", 1, "No plugin table defined (request was %s)", source);
return GET_FILE_PLUGIN_FAILED;
}
char *URL = NULL;
if(IsUrl(dest)) {
URL = const_cast<char*>(dest);
dprintf(D_FULLDEBUG, "FILETRANSFER: using destination to determine plugin type: %s\n", dest);
} else {
URL = const_cast<char*>(source);
dprintf(D_FULLDEBUG, "FILETRANSFER: using source to determine plugin type: %s\n", source);
}
const char* colon = strchr(URL, ':');
if (!colon) {
e.pushf("FILETRANSFER", 1, "Specified URL does not contain a ':' (%s)", URL);
return GET_FILE_PLUGIN_FAILED;
}
char* method = (char*) malloc(1 + (colon-URL));
strncpy(method, URL, (colon-URL));
method[(colon-URL)] = '\0';
MyString plugin;
if (plugin_table->lookup((MyString)method, plugin)) {
e.pushf("FILETRANSFER", 1, "FILETRANSFER: plugin for type %s not found!", method);
dprintf (D_FULLDEBUG, "FILETRANSFER: plugin for type %s not found!\n", method);
free(method);
return GET_FILE_PLUGIN_FAILED;
}
/*
if (absolute_path_check() ) {
dprintf(D_ALWAYS, "FILETRANSFER: NOT invoking malformed plugin named \"%s\"\n", plugin.Value());
FAIL();
}
*/
Env plugin_env;
plugin_env.Import();
if (proxy_filename && *proxy_filename) {
plugin_env.SetEnv("X509_USER_PROXY",proxy_filename);
dprintf(D_FULLDEBUG, "FILETRANSFER: setting X509_USER_PROXY env to %s\n", proxy_filename);
}
ArgList plugin_args;
plugin_args.AppendArg(plugin.Value());
plugin_args.AppendArg(source);
plugin_args.AppendArg(dest);
dprintf(D_FULLDEBUG, "FILETRANSFER: invoking: %s %s %s\n", plugin.Value(), source, dest);
FILE* plugin_pipe = my_popen(plugin_args, "r", FALSE, &plugin_env);
int plugin_status = my_pclose(plugin_pipe);
dprintf (D_ALWAYS, "FILETRANSFER: plugin returned %i\n", plugin_status);
free(method);
if (plugin_status != 0) {
e.pushf("FILETRANSFER", 1, "non-zero exit(%i) from %s\n", plugin_status, plugin.Value());
return GET_FILE_PLUGIN_FAILED;
}
return 0;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,297 | FileTransfer::ObtainAndSendTransferGoAhead(DCTransferQueue &xfer_queue,bool downloading,Stream *s,char const *full_fname,bool &go_ahead_always)
{
bool result;
bool try_again = true;
int hold_code = 0;
int hold_subcode = 0;
MyString error_desc;
result = DoObtainAndSendTransferGoAhead(xfer_queue,downloading,s,full_fname,go_ahead_always,try_again,hold_code,hold_subcode,error_desc);
if( !result ) {
SaveTransferInfo(false,try_again,hold_code,hold_subcode,error_desc.Value());
if( error_desc.Length() ) {
dprintf(D_ALWAYS,"%s\n",error_desc.Value());
}
}
return result;
}
| DoS Exec Code | 0 | FileTransfer::ObtainAndSendTransferGoAhead(DCTransferQueue &xfer_queue,bool downloading,Stream *s,char const *full_fname,bool &go_ahead_always)
{
bool result;
bool try_again = true;
int hold_code = 0;
int hold_subcode = 0;
MyString error_desc;
result = DoObtainAndSendTransferGoAhead(xfer_queue,downloading,s,full_fname,go_ahead_always,try_again,hold_code,hold_subcode,error_desc);
if( !result ) {
SaveTransferInfo(false,try_again,hold_code,hold_subcode,error_desc.Value());
if( error_desc.Length() ) {
dprintf(D_ALWAYS,"%s\n",error_desc.Value());
}
}
return result;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,298 | FileTransfer::Reaper(Service *, int pid, int exit_status)
{
FileTransfer *transobject;
bool read_failed = false;
if ( TransThreadTable->lookup(pid,transobject) < 0) {
dprintf(D_ALWAYS, "unknown pid %d in FileTransfer::Reaper!\n", pid);
return FALSE;
}
transobject->ActiveTransferTid = -1;
TransThreadTable->remove(pid);
transobject->Info.duration = time(NULL)-transobject->TransferStart;
transobject->Info.in_progress = false;
if( WIFSIGNALED(exit_status) ) {
transobject->Info.success = false;
transobject->Info.try_again = true;
transobject->Info.error_desc.sprintf("File transfer failed (killed by signal=%d)", WTERMSIG(exit_status));
read_failed = true; // do not try to read from the pipe
dprintf( D_ALWAYS, "%s\n", transobject->Info.error_desc.Value() );
} else {
if( WEXITSTATUS(exit_status) != 0 ) {
dprintf( D_ALWAYS, "File transfer completed successfully.\n" );
transobject->Info.success = true;
} else {
dprintf( D_ALWAYS, "File transfer failed (status=%d).\n",
WEXITSTATUS(exit_status) );
transobject->Info.success = false;
}
}
if( transobject->TransferPipe[1] != -1 ) {
close(transobject->TransferPipe[1]);
transobject->TransferPipe[1] = -1;
}
int n;
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.bytes,
sizeof( filesize_t) );
if(n != sizeof( filesize_t )) read_failed = true;
}
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.try_again,
sizeof( bool ) );
if(n != sizeof( bool )) read_failed = true;
}
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.hold_code,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.hold_subcode,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
int error_len = 0;
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&error_len,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
if(!read_failed && error_len) {
char *error_buf = new char[error_len];
ASSERT(error_buf);
n = read( transobject->TransferPipe[0],
error_buf,
error_len );
if(n != error_len) read_failed = true;
if(!read_failed) {
transobject->Info.error_desc = error_buf;
}
delete [] error_buf;
}
int spooled_files_len = 0;
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&spooled_files_len,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
if(!read_failed && spooled_files_len) {
char *spooled_files_buf = new char[spooled_files_len];
ASSERT(spooled_files_buf);
n = read( transobject->TransferPipe[0],
spooled_files_buf,
spooled_files_len );
if(n != spooled_files_len) read_failed = true;
if(!read_failed) {
transobject->Info.spooled_files = spooled_files_buf;
}
delete [] spooled_files_buf;
}
if(read_failed) {
transobject->Info.success = false;
transobject->Info.try_again = true;
if( transobject->Info.error_desc.IsEmpty() ) {
transobject->Info.error_desc.sprintf("Failed to read status report from file transfer pipe (errno %d): %s",errno,strerror(errno));
dprintf(D_ALWAYS,"%s\n",transobject->Info.error_desc.Value());
}
}
close(transobject->TransferPipe[0]);
transobject->TransferPipe[0] = -1;
if ( transobject->Info.success && transobject->upload_changed_files &&
transobject->IsClient() && transobject->Info.type == DownloadFilesType ) {
time(&(transobject->last_download_time));
transobject->BuildFileCatalog(0, transobject->Iwd, &(transobject->last_download_catalog));
sleep(1);
}
if (transobject->ClientCallback) {
dprintf(D_FULLDEBUG,
"Calling client FileTransfer handler function.\n");
((transobject->ClientCallbackClass)->*(transobject->ClientCallback))(transobject);
}
return TRUE;
}
| DoS Exec Code | 0 | FileTransfer::Reaper(Service *, int pid, int exit_status)
{
FileTransfer *transobject;
bool read_failed = false;
if ( TransThreadTable->lookup(pid,transobject) < 0) {
dprintf(D_ALWAYS, "unknown pid %d in FileTransfer::Reaper!\n", pid);
return FALSE;
}
transobject->ActiveTransferTid = -1;
TransThreadTable->remove(pid);
transobject->Info.duration = time(NULL)-transobject->TransferStart;
transobject->Info.in_progress = false;
if( WIFSIGNALED(exit_status) ) {
transobject->Info.success = false;
transobject->Info.try_again = true;
transobject->Info.error_desc.sprintf("File transfer failed (killed by signal=%d)", WTERMSIG(exit_status));
read_failed = true; // do not try to read from the pipe
dprintf( D_ALWAYS, "%s\n", transobject->Info.error_desc.Value() );
} else {
if( WEXITSTATUS(exit_status) != 0 ) {
dprintf( D_ALWAYS, "File transfer completed successfully.\n" );
transobject->Info.success = true;
} else {
dprintf( D_ALWAYS, "File transfer failed (status=%d).\n",
WEXITSTATUS(exit_status) );
transobject->Info.success = false;
}
}
if( transobject->TransferPipe[1] != -1 ) {
close(transobject->TransferPipe[1]);
transobject->TransferPipe[1] = -1;
}
int n;
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.bytes,
sizeof( filesize_t) );
if(n != sizeof( filesize_t )) read_failed = true;
}
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.try_again,
sizeof( bool ) );
if(n != sizeof( bool )) read_failed = true;
}
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.hold_code,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&transobject->Info.hold_subcode,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
int error_len = 0;
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&error_len,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
if(!read_failed && error_len) {
char *error_buf = new char[error_len];
ASSERT(error_buf);
n = read( transobject->TransferPipe[0],
error_buf,
error_len );
if(n != error_len) read_failed = true;
if(!read_failed) {
transobject->Info.error_desc = error_buf;
}
delete [] error_buf;
}
int spooled_files_len = 0;
if(!read_failed) {
n = read( transobject->TransferPipe[0],
(char *)&spooled_files_len,
sizeof( int ) );
if(n != sizeof( int )) read_failed = true;
}
if(!read_failed && spooled_files_len) {
char *spooled_files_buf = new char[spooled_files_len];
ASSERT(spooled_files_buf);
n = read( transobject->TransferPipe[0],
spooled_files_buf,
spooled_files_len );
if(n != spooled_files_len) read_failed = true;
if(!read_failed) {
transobject->Info.spooled_files = spooled_files_buf;
}
delete [] spooled_files_buf;
}
if(read_failed) {
transobject->Info.success = false;
transobject->Info.try_again = true;
if( transobject->Info.error_desc.IsEmpty() ) {
transobject->Info.error_desc.sprintf("Failed to read status report from file transfer pipe (errno %d): %s",errno,strerror(errno));
dprintf(D_ALWAYS,"%s\n",transobject->Info.error_desc.Value());
}
}
close(transobject->TransferPipe[0]);
transobject->TransferPipe[0] = -1;
if ( transobject->Info.success && transobject->upload_changed_files &&
transobject->IsClient() && transobject->Info.type == DownloadFilesType ) {
time(&(transobject->last_download_time));
transobject->BuildFileCatalog(0, transobject->Iwd, &(transobject->last_download_catalog));
sleep(1);
}
if (transobject->ClientCallback) {
dprintf(D_FULLDEBUG,
"Calling client FileTransfer handler function.\n");
((transobject->ClientCallbackClass)->*(transobject->ClientCallback))(transobject);
}
return TRUE;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
13,299 | FileTransfer::ReceiveTransferGoAhead(
Stream *s,
char const *fname,
bool downloading,
bool &go_ahead_always)
{
bool try_again = true;
int hold_code = 0;
int hold_subcode = 0;
MyString error_desc;
bool result;
int alive_interval;
int old_timeout;
const int slop_time = 20; // extra time to wait when alive_interval expires
const int min_alive_interval = 300;
alive_interval = clientSockTimeout;
if( alive_interval < min_alive_interval ) {
alive_interval = min_alive_interval;
}
old_timeout = s->timeout(alive_interval + slop_time);
result = DoReceiveTransferGoAhead(s,fname,downloading,go_ahead_always,try_again,hold_code,hold_subcode,error_desc,alive_interval);
s->timeout( old_timeout );
if( !result ) {
SaveTransferInfo(false,try_again,hold_code,hold_subcode,error_desc.Value());
if( error_desc.Length() ) {
dprintf(D_ALWAYS,"%s\n",error_desc.Value());
}
}
return result;
}
| DoS Exec Code | 0 | FileTransfer::ReceiveTransferGoAhead(
Stream *s,
char const *fname,
bool downloading,
bool &go_ahead_always)
{
bool try_again = true;
int hold_code = 0;
int hold_subcode = 0;
MyString error_desc;
bool result;
int alive_interval;
int old_timeout;
const int slop_time = 20; // extra time to wait when alive_interval expires
const int min_alive_interval = 300;
alive_interval = clientSockTimeout;
if( alive_interval < min_alive_interval ) {
alive_interval = min_alive_interval;
}
old_timeout = s->timeout(alive_interval + slop_time);
result = DoReceiveTransferGoAhead(s,fname,downloading,go_ahead_always,try_again,hold_code,hold_subcode,error_desc,alive_interval);
s->timeout( old_timeout );
if( !result ) {
SaveTransferInfo(false,try_again,hold_code,hold_subcode,error_desc.Value());
if( error_desc.Length() ) {
dprintf(D_ALWAYS,"%s\n",error_desc.Value());
}
}
return result;
}
| @@ -2716,7 +2716,7 @@ FileTransfer::DoUpload(filesize_t *total_bytes, ReliSock *s)
}
// condor_basename works for URLs
- dest_filename.sprintf_cat( condor_basename(filename) );
+ dest_filename.sprintf_cat( "%s", condor_basename(filename) );
}
// for command 999, this string must equal the Attribute "Filename" in | CWE-134 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.