Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 229189
Collapse All | Expand All

(-)src-native-new/src/shared/processControlUtil/ProcessControlUtil.c (-7 / +27 lines)
Lines 762-768 Link Here
762
char *substring(const char *str, int start, int end) {
762
char *substring(const char *str, int start, int end) {
763
    char * dest;
763
    char * dest;
764
    
764
    
765
	dest = malloc((end-start+10) * sizeof(char));
765
	dest = tptp_malloc((end-start+10) * sizeof(char));
766
     
766
     
767
    strncpy(dest, str + start, end - start);
767
    strncpy(dest, str + start, end - start);
768
768
Lines 812-817 Link Here
812
812
813
}
813
}
814
814
815
/** Is the string (str) in the given classpath (classpath), with the classpath beginning at the first character, and 
816
    ending at the given length*/
817
int isStringInClasspathRange(const char *classpath, const char *str, int length) {
818
	char * tempVal;
819
	int result = 0;
820
821
	tempVal = (char *)tptp_malloc(sizeof(char) * length + 10);
822
	
823
	memcpy(tempVal, classpath, sizeof(char) * length);
824
	
825
	tempVal[length] = 0;
826
827
	result = isStringInClasspath(tempVal, str);
828
829
	tptp_free(tempVal);
830
    
831
	return result;
832
}
833
834
815
835
816
/** Returns 1 if the envValue is already in the environment variable under envName, or 0 otherwise. */
836
/** Returns 1 if the envValue is already in the environment variable under envName, or 0 otherwise. */
817
int existsInEnv(char *envStart, int currentEnd, char *envName, char *envValue) {
837
int existsInEnv(char *envStart, int currentEnd, char *envName, char *envValue) {
Lines 843-858 Link Here
843
			// If the value we are looking for is found in the environment variable...
869
			// If the value we are looking for is found in the environment variable...
844
			if(isStringInClasspath(afterEquals, envValue)) {
870
			if(isStringInClasspath(afterEquals, envValue)) {
845
				
871
				
846
				free(beforeEquals);
872
				tptp_free(beforeEquals);
847
				free(afterEquals);
873
				tptp_free(afterEquals);
848
				return 1;
874
				return 1;
849
875
850
			}
876
			}
851
877
852
		}
878
		}
853
879
854
		free(beforeEquals);
880
		tptp_free(beforeEquals);
855
		free(afterEquals);
881
		tptp_free(afterEquals);
856
882
857
		// Advance past the null terminator in the environment variable string
883
		// Advance past the null terminator in the environment variable string
858
		x += strlen(env)+1;
884
		x += strlen(env)+1;
Lines 970-976 Link Here
970
						currentLength=keyLength+1+valueLength;
996
						currentLength=keyLength+1+valueLength;
971
					}
997
					}
972
					// If the variable is an APPEND, and the value being appended isn't already present in the environment variable...
998
					// If the variable is an APPEND, and the value being appended isn't already present in the environment variable...
973
					else if(varNode->position==APPEND && !isStringInClasspath(&parent[parentOffset], varNode->value) && !isStringInClasspath(&childEnv[childOffset], varNode->value)) {
999
					else if(varNode->position==APPEND && !isStringInClasspath(&parent[parentOffset], varNode->value) && !isStringInClasspathRange(&childEnv[childOffset], varNode->value, currentLength)) {
974
						/* Ensure the buffer is large enough to add the data */
1000
						/* Ensure the buffer is large enough to add the data */
975
						if((childOffset+currentLength+1+valueLength) >= bufferSize) {
1001
						if((childOffset+currentLength+1+valueLength) >= bufferSize) {
976
							int neededSize=((childOffset+currentLength+1+valueLength)-bufferSize)+1;
1002
							int neededSize=((childOffset+currentLength+1+valueLength)-bufferSize)+1;
Lines 987-993 Link Here
987
						currentLength+=valueLength+1;
1013
						currentLength+=valueLength+1;
988
					}
1014
					}
989
					// If the variable is a PREPEND, and the value being prepended isn't already present in the environment variable...
1015
					// If the variable is a PREPEND, and the value being prepended isn't already present in the environment variable...
990
					else if(varNode->position==PREPEND && !isStringInClasspath(&parent[parentOffset], varNode->value) && !isStringInClasspath(&childEnv[childOffset], varNode->value)) {
1016
					else if(varNode->position==PREPEND && !isStringInClasspath(&parent[parentOffset], varNode->value) &&  !isStringInClasspathRange(&childEnv[childOffset], varNode->value, currentLength)) {
991
						char *temp;
1017
						char *temp;
992
						if((childOffset+keyLength+1+valueLength+1+(currentLength-keyLength-1)) >= bufferSize) {
1018
						if((childOffset+keyLength+1+valueLength+1+(currentLength-keyLength-1)) >= bufferSize) {
993
							int neededSize=((childOffset+keyLength+1+valueLength+1+(currentLength-keyLength-1))-bufferSize)+1;
1019
							int neededSize=((childOffset+keyLength+1+valueLength+1+(currentLength-keyLength-1))-bufferSize)+1;

Return to bug 229189