#include <bms/sbport.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <time.h> /* ctime() */
#include <pwd.h>
#include <errno.h>
int Client_Channel_Termios(protocol_request_ptr prot);
int Client_Enhanced_Spawn(protocol_request_ptr prot);
-#if defined(_AIX) || defined(DEC)
+#if defined(_AIX) || defined(DEC) || defined(linux)
# define SA_HANDLER_INT_ARG
#endif /* _AIX || DEC */
/* set up log file path */
log_path = XeSBTempPath((XeString)"DTSPCD.log");
- freopen("/dev/null", "w", stderr);
+ if(NULL == freopen("/dev/null", "w", stderr)) {
+ fprintf(stderr, "Unable to open /dev/null\n");
+ exit(EXIT_FAILURE);
+ }
/* Process arguments and set flags. */
for (i=1; i < argc; i++) {
/* Open an error log with whatever name the library wants to use */
SPC_Open_Log(log_path, FALSE);
SPC_Print_Protocol = spc_logF;
- freopen(log_path, "a", stderr);
+ if(NULL == (stderr = freopen(log_path, "a", stderr))) {
+ fprintf(stderr, "Unable to reopen '%s' as stderr\n", log_path);
+ exit(EXIT_FAILURE);
+ }
setbuf(stderr, NULL);
}
*/
i++;
if (i != argc) {
- (void) sprintf (tmp, "%s=%s", MOUNT_POINT, argv[i]);
+ (void) snprintf (tmp, sizeof(tmp), "%s=%s", MOUNT_POINT, argv[i]);
if (putenv (tmp) == 0) {
SPC_Format_Log((XeString)"Mount point set to '%s'.", argv[i]);
SPC_mount_point_env_var = (char *) malloc (strlen (tmp) + 1);
SPC_Client);
if (exit_timeout != SPCD_NO_TIMER) {
+ memset(&alarm_vector, 0, sizeof(struct sigaction));
alarm_vector.sa_handler = SPCD_Alarm_Handler;
alarm_vector.sa_flags = 0;
(void) sigaction (SIGALRM, &alarm_vector, (struct sigaction *)NULL);
if (exit_timeout != SPCD_NO_TIMER)
(void) alarm (exit_timeout * 60);
request_pending = SPCD_REQUEST_PENDING;
+ SPC_Free_Protocol_Ptr(prot);
return;
}
FAILED_FILE_NAME, NULL, NULL);
FREE_USER_PASS(username, passwd);
SPC_Error(SPC_Bad_Username);
+ free(hostinfo);
return(SPC_ERROR);
}
else {
/* Allocate space for tmppath, spc_prefix, and spc_suffix. */
tmpfile = (char *)malloc((strlen(tmppath) + strlen(spc_prefix) +
strlen(spc_suffix) + 1) * sizeof(char));
- sprintf(tmpfile, "%s%s%s", tmppath, spc_prefix, spc_suffix);
+ if(tmpfile) {
+ snprintf(tmpfile, sizeof(tmpfile), "%s%s%s", tmppath, spc_prefix, spc_suffix);
+ }
}
else {
#if 0
FAILED_FILE_NAME, NULL, NULL);
FREE_USER_PASS(username, passwd);
SPC_Error(SPC_Bad_Username);
+ free(hostinfo);
return(SPC_ERROR);
}
FAILED_FILE_NAME, NULL, NULL);
SPC_Format_Log("+++> FAILURE: cannot malloc.");
SPC_Error(SPC_Out_Of_Memory);
+ free(hostinfo);
return(SPC_ERROR);
}
XeSPCAddInput(channel, SPCD_Handle_Application_Data, channel);
XeSPCRegisterTerminator(channel, SPCD_Termination_Handler, channel);
- return((int) channel);
+ return((int) (intptr_t) channel);
}
/*----------------------------------------------------------------------+*/
return;
if (SPC_pid_list != NULL)
- for (i=0; SPC_pid_list[i] != NULL; i++) {
+ for (i=0; SPC_pid_list[i] != 0; i++) {
if (SPC_pid_list[i] != SPCD_DEAD_PROCESS) {
/*
* Have at least one sub- process running so reset the