CVE-2015-5232 (published 2017-06-07T20:29Z)

Race conditions in opa-fm before 10.4.0.0.196 and opa-ff before 10.4.0.0.197.

Severity: HIGH
CVSS v2 base score: 9.3 (AV:N/AC:M/Au:N/C:C/I:C/A:C)
CVSS v3 base score: 8.1, HIGH (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-362
cwe_name: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
description: The product contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
extended_description: 
            This can have security implications when the expected synchronization is in security-critical code, such as recording whether a user is authenticated or modifying important state information that should not be influenced by an outsider.
            A race condition occurs within concurrent environments, and is effectively a property of a code sequence. Depending on the context, a code sequence may be in the form of a function call, a small number of instructions, a series of program invocations, etc.
            A race condition violates these properties, which are closely related:
               
                  Exclusivity - the code sequence is given exclusive access to the shared resource, i.e., no other code sequence can modify properties of the shared resource before the original sequence has completed execution.
                  Atomicity - the code sequence is behaviorally atomic, i.e., no other thread or process can concurrently execute the same sequence of instructions (or a subset) against the same resource.
               
            A race condition exists when an "interfering code sequence" can still access the shared resource, violating exclusivity. Programmers may assume that certain code sequences execute too quickly to be affected by an interfering code sequence; when they are not, this violates atomicity. For example, the single "x++" statement may appear atomic at the code layer, but it is actually non-atomic at the instruction layer, since it involves a read (the original value of x), followed by a computation (x+1), followed by a write (save the result to x).
            The interfering code sequence could be "trusted" or "untrusted." A trusted interfering code sequence occurs within the product; it cannot be modified by the attacker, and it can only be invoked indirectly. An untrusted interfering code sequence can be authored directly by the attacker, and typically it is external to the vulnerable product.
         
         

Fix information:
repo_url: https://github.com/01org/opa-fm
commit_details: repo_url: https://github.com/01org/opa-fm
author: Brendan Cunningham
author_date: 2015-09-18 11:47:10-04:00
msg: Fix scripts and code that use well-known tmp files.
repository: repo_url: https://github.com/01org/opa-fm
repo_name: cornelisnetworks/opa-fm
repo_language: C
owner: 01org
file_changes: filename: hsm_config_srvr_data.h
change_type: ModificationType.MODIFY
diff: @@ -32,10 +32,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "hsm_config_srvr_api.h"
 
-#define HSM_FM_SCK_PREFIX	"/tmp/"
+#define HSM_FM_SCK_PREFIX	"/opt/opafm/"
 #define HSM_FM_SCK_SM		"sm_"
 #define HSM_FM_SCK_PM		"pm_"
-#define HSM_FM_SCK_BM		"bm_"
 #define HSM_FM_SCK_FE		"fe_"
 
 typedef struct	_fm_config_conx_hdl{

programming_language: C
filename: fm_cmd.c
change_type: ModificationType.MODIFY
diff: @@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <unistd.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/stat.h>
@@ -48,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <time.h>
 #include "hsm_config_client_api.h"
 #include "hsm_config_client_data.h"
+#include "hsm_com_client_data.h"
 
 extern int   getopt(int, char *const *, const char *);
 
@@ -1045,7 +1047,7 @@ int sm_skip_attr_write(p_fm_config_conx_hdlt hdl, fm_mgr_type_t mgr, int argc, c
 }
 
 int main(int argc, char *argv[]) {
-	p_fm_config_conx_hdlt	hdl;
+	p_fm_config_conx_hdlt	hdl = NULL;
 	int						instance = 0;
 	fm_mgr_config_errno_t	res;
 	char					*rem_addr = NULL;
@@ -1087,18 +1089,19 @@ int main(int argc, char *argv[]) {
 	if((res = fm_mgr_config_init(&hdl,instance, rem_addr, community)) != FM_CONF_OK)
 	{
 		fprintf(stderr, "Failed to initialize the client handle: %d\n", res);
-		goto die_clean;
+		goto cleanup;
 	}
 
 	if((res = fm_mgr_config_connect(hdl)) != FM_CONF_OK)
 	{
 		fprintf(stderr, "Failed to connect: (%d) %s\n",res,fm_mgr_get_error_str(res));
-		goto die_clean;
+		goto cleanup;
 	}
 
 	for(i=0;i<commandListLen;i++){
 		if(strcmp(command,commandList[i].name) == 0){
-			return commandList[i].cmdPtr(hdl, commandList[i].mgr, (argc - optind), &argv[optind]);
+			res = commandList[i].cmdPtr(hdl, commandList[i].mgr, (argc - optind), &argv[optind]);
+			goto cleanup;
 		}
 	}
 
@@ -1106,7 +1109,26 @@ int main(int argc, char *argv[]) {
 	usage(argv[0]);
 	res = -1;
 
-die_clean:
-	if (hdl) free(hdl);
+cleanup:
+	if (hdl)
+	{
+		if (hdl->sm_hdl)
+		{
+			if (hdl->sm_hdl->c_path[0])
+				unlink(hdl->sm_hdl->c_path);
+		}
+		if (hdl->pm_hdl)
+		{
+			if (hdl->pm_hdl->c_path[0])
+				unlink(hdl->pm_hdl->c_path);
+		}
+		if (hdl->fe_hdl)
+		{
+			if (hdl->fe_hdl->c_path[0])
+				unlink(hdl->fe_hdl->c_path);
+		}
+		free(hdl);
+	}
+
 	return res;
 }

programming_language: C
filename: hsm_com_client.c
change_type: ModificationType.MODIFY
diff: @@ -245,6 +245,7 @@ unix_client_connect(hsm_com_client_hdl_t *hdl)
 {
 	int					fd, len;
 	struct sockaddr_un	unix_addr;
+	hsm_com_errno_t		res = HSM_COM_OK;
 
 	if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) 
 	{
@@ -257,8 +258,8 @@ unix_client_connect(hsm_com_client_hdl_t *hdl)
 	
 	if(strlen(hdl->c_path) >= sizeof(unix_addr.sun_path))
 	{
-		close(fd);
-		return HSM_COM_PATH_ERR;
+		res = HSM_COM_PATH_ERR;
+		goto cleanup;
 	}
 
 	snprintf(unix_addr.sun_path, sizeof(unix_addr.sun_path), "%s", hdl->c_path);
@@ -269,17 +270,14 @@ unix_client_connect(hsm_com_client_hdl_t *hdl)
 
 	if(bind(fd, (struct sockaddr *)&unix_addr, len) < 0)
 	{
-		unlink(hdl->c_path);
-		close(fd);
-
-		return HSM_COM_BIND_ERR;
+		res = HSM_COM_BIND_ERR;
+		goto cleanup;
 	}
 
 	if(chmod(unix_addr.sun_path, S_IRWXU) < 0)
 	{
-		unlink(hdl->c_path);
-		close(fd);
-		return HSM_COM_CHMOD_ERR;
+		res = HSM_COM_CHMOD_ERR;
+		goto cleanup;
 	}
 
 	memset(&unix_addr,0,sizeof(unix_addr));
@@ -292,9 +290,8 @@ unix_client_connect(hsm_com_client_hdl_t *hdl)
 
 	if (connect(fd, (struct sockaddr *) &unix_addr, len) < 0) 
 	{
-		unlink(hdl->c_path);
-		close(fd);
-		return HSM_COM_CONX_ERR;
+		res = HSM_COM_CONX_ERR;
+		goto cleanup;
 	}
 
 	hdl->client_fd = fd;
@@ -304,12 +301,14 @@ unix_client_connect(hsm_com_client_hdl_t *hdl)
 	if(unix_sck_send_conn(hdl, 2) != HSM_COM_OK)
 	{
 		hdl->client_state = HSM_COM_C_STATE_IN;
-		return HSM_COM_SEND_ERR;
+		res = HSM_COM_SEND_ERR;
 	}
 
+	return res;
 
-
-	return HSM_COM_OK;
+cleanup:
+	close(fd);
+	return res;
 
 }
 

programming_language: C
filename: hsm_com_client_api.c
change_type: ModificationType.MODIFY
diff: @@ -98,6 +98,11 @@ hcom_client_init
 	strcpy(hdl->s_path,server_path);
 	strcpy(hdl->c_path,client_path);
 
+	if (mkstemp(hdl->c_path) == -1)
+	{
+		res = HSM_COM_PATH_ERR;
+		goto cleanup;
+	}
 
 	hdl->client_state = HSM_COM_C_STATE_IN;
 

programming_language: C
filename: hsm_config_client.c
change_type: ModificationType.MODIFY
diff: @@ -52,13 +52,10 @@ fm_mgr_config_mgr_connect
 	char                    c_path[256];
 	char                    *mgr_prefix;
 	p_hsm_com_client_hdl_t  *mgr_hdl;
-	pid_t                   pid;
 
 	memset(s_path,0,sizeof(s_path));
 	memset(c_path,0,sizeof(c_path));
 
-	pid = getpid();
-
 	switch ( mgr )
 	{
 		case FM_MGR_SM:
@@ -80,8 +77,7 @@ fm_mgr_config_mgr_connect
 	// Fill in the paths for the server and client sockets.
 	sprintf(s_path,"%s%s%d",HSM_FM_SCK_PREFIX,mgr_prefix,hdl->instance);
 
-	sprintf(c_path,"%s%s%d_C_%lu",HSM_FM_SCK_PREFIX,mgr_prefix,
-			hdl->instance, (long unsigned)pid);
+	sprintf(c_path,"%s%s%d_C_XXXXXX",HSM_FM_SCK_PREFIX,mgr_prefix,hdl->instance);
 
 	if ( *mgr_hdl == NULL )
 	{
@@ -147,17 +143,7 @@ fm_mgr_config_init
 		}
 	}
 
-
-	return res;
-
-
-	cleanup:
-
-	if ( hdl ) {
-		free(hdl);
-		hdl = NULL;
-	}
-
+cleanup:
 	return res;
 }
 

programming_language: C
filename: hsm_config_client_data.h
change_type: ModificationType.MODIFY
diff: @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "hsm_config_client_api.h"
 
-#define HSM_FM_SCK_PREFIX	"/tmp/"
+#define HSM_FM_SCK_PREFIX	"/opt/opafm/"
 #define HSM_FM_SCK_SM		"sm_"
 #define HSM_FM_SCK_PM		"pm_"
 #define HSM_FM_SCK_FE		"fe_"

programming_language: C
filename: hsm_config_data.h
change_type: ModificationType.MODIFY
diff: @@ -33,10 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "hsm_config_api.h"
 #include "snmp_com_api.h"
 
-#define HSM_FM_SCK_PREFIX	"/tmp/"
+#define HSM_FM_SCK_PREFIX	"/opt/opafm/"
 #define HSM_FM_SCK_SM		"sm_"
 #define HSM_FM_SCK_PM		"pm_"
-#define HSM_FM_SCK_BM		"bm_"
 #define HSM_FM_SCK_FE		"fe_"
 
 typedef struct	_fm_config_conx_hdl{

programming_language: C
filename: opafm.sh
change_type: ModificationType.MODIFY
diff: @@ -89,7 +89,7 @@ my_rc_status_all=0
 my_rc_exit()     { exit $my_rc_status_all; }
 my_rc_status()   { my_rc_status_all=$(($my_rc_status_all || $?)); }
 
-temp=/tmp/ifsfm$$
+temp=$(mktemp "/tmp/ifsfmXXXXX")
 
 trap "rm -rf $tempdir; exit 1" 1 2 3 9 1
 

programming_language: Shell
filename: opafmctrl.sh
change_type: ModificationType.MODIFY
diff: @@ -87,7 +87,7 @@ my_rc_status_all=0
 my_rc_exit()     { exit $my_rc_status_all; }
 my_rc_status()   { my_rc_status_all=$(($my_rc_status_all || $?)); }
 
-temp=/tmp/ifsfm$$
+temp=$(mktemp "/tmp/ifsfmXXXXX")
 invalid_config()
 {
 	local i

programming_language: Shell
repo_url: https://github.com/01org/opa-fm
commit_details: repo_url: https://github.com/01org/opa-fm
author: Brendan Cunningham
author_date: 2015-09-21 17:16:46-04:00
msg: Fix scripts that use well-known temp files.
repository: repo_url: https://github.com/01org/opa-fm
repo_name: cornelisnetworks/opa-fm
repo_language: C
owner: 01org
file_changes: filename: config_diff.sh
change_type: ModificationType.MODIFY
diff: @@ -30,9 +30,10 @@
 
 # [ICS VERSION STRING: unknown]
 
-TEMP1=/tmp/smdiffa$$
-TEMP2=/tmp/smdiffb$$
+TEMP1=`mktemp`
+TEMP2=`mktemp`
 trap "rm -f $TEMP1 $TEMP2; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $TEMP1 $TEMP2" EXIT
 
 Usage()
 {

programming_language: Shell
filename: config_generate.sh
change_type: ModificationType.MODIFY
diff: @@ -30,8 +30,9 @@
 
 # [ICS VERSION STRING: unknown]
 
-TEMP=/tmp/smgen$$
+TEMP=`mktemp`
 trap "rm -f $TEMP; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $TEMP" EXIT
 
 Usage()
 {

programming_language: Shell
repo_url: https://github.com/01org/opa-ff
commit_details: repo_url: https://github.com/01org/opa-ff
author: Brendan Cunningham
author_date: 2015-09-16 14:21:46-04:00
msg: Fix scripts that use well-known temp files.
repository: repo_url: https://github.com/01org/opa-ff
repo_name: cornelisnetworks/opa-ff
repo_language: C
owner: 01org
file_changes: filename: opascpall.sh
change_type: ModificationType.MODIFY
diff: @@ -31,7 +31,9 @@
 # [ICS VERSION STRING: unknown]
 # copy a file to all hosts
 
-trap "exit 1" SIGHUP SIGTERM SIGINT
+temp="$(mktemp --tmpdir "opascpall.XXXXXX")"
+trap "rm -f $temp; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $temp" EXIT
 
 # optional override of defaults
 if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
@@ -43,7 +45,7 @@ fi
 
 . /opt/opa/tools/ff_funcs
 
-temp=/tmp/opascpall$$
+temp=`mktemp`
 trap "rm -f $temp" 1 2 3 9 15
 
 Usage_full()

programming_language: Shell
filename: opatest.sh
change_type: ModificationType.MODIFY
diff: @@ -49,7 +49,7 @@ then
 	export FF_IPOIB_SUFFIX=""
 fi
 
-temp=/tmp/opatest$$
+temp=`mktemp`
 trap "rm -f $temp" 1 2 3 9 15
 
 # identify how we are being run, affects valid options and usage

programming_language: Shell
filename: opadisablehosts.sh
change_type: ModificationType.MODIFY
diff: @@ -33,8 +33,9 @@
 
 # disable the specified set of hosts
 
-tempfile=/tmp/opadisablehosts$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 Usage_full()
 {

programming_language: Shell
filename: opaenableports.sh
change_type: ModificationType.MODIFY
diff: @@ -33,8 +33,9 @@
 
 # reenable the specified set of ports
 
-tempfile=/tmp/opaenableports$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 # optional override of defaults
 if [ -f /etc/sysconfig/opa/opafastfabric.conf ]

programming_language: Shell
filename: opaextractbadlinks.sh
change_type: ModificationType.MODIFY
diff: @@ -36,8 +36,9 @@
 TOOLSDIR=${TOOLSDIR:-/opt/opa/tools}
 BINDIR=${BINDIR:-/usr/sbin}
 
-tempfile=/tmp/opaextractbadlinks$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 Usage_full()
 {

programming_language: Shell
filename: opaextractlids.sh
change_type: ModificationType.MODIFY
diff: @@ -35,8 +35,9 @@
 TOOLSDIR=${TOOLSDIR:-/opt/opa/tools}
 BINDIR=${BINDIR:-/usr/sbin}
 
-tempfile=/tmp/opaextractlids$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 Usage_full()
 {

programming_language: Shell
filename: opaextractsellinks.sh
change_type: ModificationType.MODIFY
diff: @@ -36,8 +36,9 @@
 TOOLSDIR=${TOOLSDIR:-/opt/opa/tools}
 BINDIR=${BINDIR:-/usr/sbin}
 
-tempfile=/tmp/opaextractsellinks$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 Usage_full()
 {

programming_language: Shell
filename: opacabletest.sh
change_type: ModificationType.MODIFY
diff: @@ -32,8 +32,9 @@
 
 # start and stop HFI-SW and/or ISL cable Bit Error Rate tests
 
-tempfile=/tmp/opacabletest$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 # optional override of defaults
 if [ -f /etc/sysconfig/opa/opafastfabric.conf ]

programming_language: Shell
filename: opagenswitches.sh
change_type: ModificationType.MODIFY
diff: @@ -39,9 +39,6 @@
 # information obtained via opareport -o links (live fabric or snapshot).
 
 
-## Includes
-trap "exit 1" SIGHUP SIGTERM SIGINT
-
 # optional override of defaults
 if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
 then
@@ -160,6 +157,9 @@ clean_files()
 	fi
 }	# End of clean_files()
 
+trap 'clean_files; exit 1' SIGINT SIGHUP SIGTERM 
+trap clean_files EXIT
+
 Usage_full()
 {
 	echo "Usage: opagenswitches [-t portsfile] [-p ports] [-R]" >&2
@@ -221,7 +221,6 @@ Usage()
 	echo "for example:" >&2
 	echo "   opagenswitches" >&2
 	echo "   opagenswitches -T topology.0:0.xml" >&2
-	clean_files
 	exit 2
 }	# End of Usage()
 

programming_language: Shell
filename: opalinkanalysis.sh
change_type: ModificationType.MODIFY
diff: @@ -32,8 +32,9 @@
 
 # analyzes all the links in the fabric
 
-tempfile=/tmp/opalinkanalysis$$
+tempfile=`mktemp`
 trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $tempfile" EXIT
 
 # optional override of defaults
 if [ -f /etc/sysconfig/opa/opafastfabric.conf ]

programming_language: Shell
filename: opamanageswitch.sh
change_type: ModificationType.MODIFY
diff: @@ -366,8 +366,7 @@ fwUpdate)
 	else
 		fn=$fileNameArg
 	fi
-	tmpdir=/tmp/12200FW$$
-	mkdir $tmpdir
+	tmpdir=`mktemp -d`
 	cd $tmpdir
 	tar xzf $fn > /dev/null 2>&1
 

programming_language: Shell
filename: opaxlattopology.sh
change_type: ModificationType.MODIFY
diff: @@ -220,6 +220,23 @@ debug_6=
 debug_7=
 #echo "DEBUG-x.y: 0:$debug_0: 1:$debug_1: 2:$debug_2: 3:$debug_3: 4:$debug_4: 5:$debug_5: 6:$debug_6: 7:$debug_7:"
 
+function clean_tempfiles() {
+  if [ $fl_clean == 1 ]
+    then
+    rm -f $FILE_TEMP
+    rm -f $FILE_TEMP2
+    rm -f $FILE_LINKSUM
+    rm -f $FILE_LINKSUM_NOCORE
+    rm -f $FILE_LINKSUM_NOCABLE
+    rm -f $FILE_NODEFIS
+    rm -f $FILE_NODESWITCHES
+    rm -f $FILE_NODELEAVES
+    rm -f $FILE_NODECHASSIS
+  fi
+}
+
+trap 'clean_tempfiles; exit 1' SIGINT SIGHUP SIGTERM
+trap 'clean_tempfiles' EXIT
 
 ## Local functions:
 functout=
@@ -400,18 +417,7 @@ gen_topology()
   echo "</Report>" >> $FILE_TOPOLOGY_OUT
 
   # Clean temporary files
-  if [ $fl_clean == 1 ]
-    then
-    rm -f $FILE_TEMP
-    rm -f $FILE_TEMP2
-    rm -f $FILE_LINKSUM
-    rm -f $FILE_LINKSUM_NOCORE
-    rm -f $FILE_LINKSUM_NOCABLE
-    rm -f $FILE_NODEFIS
-    rm -f $FILE_NODESWITCHES
-    rm -f $FILE_NODELEAVES
-    rm -f $FILE_NODECHASSIS
-  fi
+  clean_tempfiles
 }  # End of gen_topology
 
 # Process rack group name; check for non-null name and find in tb_group[].
@@ -593,9 +599,6 @@ proc_switch()
 
 ## Main function:
 
-rm -f $FILE_DEBUG
-rm -f $FILE_DEBUG2
-
 # Get options
 while getopts c:d:i:Kv:? option
 do

programming_language: Shell
filename: opaxlattopology_cust.sh
change_type: ModificationType.MODIFY
diff: @@ -177,6 +177,16 @@ debug_7=
 ## Local functions:
 functout=
 
+function clean_tempfiles() {
+	if [ $fl_clean == 1 ]
+	then
+		rm -f $FILE_TEMP $FILE_TEMP2
+	fi
+}
+
+trap 'clean_tempfiles; exit 1' SIGINT SIGHUP SIGTERM
+trap 'clean_tempfiles' EXIT
+
 # Output usage information
 usage_full()
 {
@@ -260,9 +270,6 @@ proc_coreswitch()
 
 ## Main function:
 
-rm -f $FILE_DEBUG
-rm -f $FILE_DEBUG2
-
 # Get options
 while getopts c:i:Ks:t:T:v:? option
 do
@@ -444,11 +451,7 @@ done	# End of for (( ix=0 ; $ix <= $max_coreswitch ; ix=$[ix+1] ))
 echo ",,,,,,,,,,,,,," >> ${file_topology_out}
 
 # Clean temporary files
-if [ $fl_clean == 1 ]
-	then
-	rm -f $FILE_TEMP
-	rm -f $FILE_TEMP2
-fi
+clean_tempfiles
 
 display_progress "Done"
 exit 0

programming_language: Shell
filename: config_diff.sh
change_type: ModificationType.MODIFY
diff: @@ -30,9 +30,10 @@
 
 # [ICS VERSION STRING: unknown]
 
-TEMP1=/tmp/smdiffa$$
-TEMP2=/tmp/smdiffb$$
+TEMP1=`mktemp`
+TEMP2=`mktemp`
 trap "rm -f $TEMP1 $TEMP2; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $TEMP1 $TEMP2" EXIT
 
 Usage()
 {

programming_language: Shell
filename: config_generate.sh
change_type: ModificationType.MODIFY
diff: @@ -30,8 +30,9 @@
 
 # [ICS VERSION STRING: unknown]
 
-TEMP=/tmp/smgen$$
+TEMP=`mktemp`
 trap "rm -f $TEMP; exit 1" SIGHUP SIGTERM SIGINT
+trap "rm -f $TEMP" EXIT
 
 Usage()
 {

programming_language: Shell