Sfoglia il codice sorgente

cplc: safety checks for parameters

Daniel-Constantin Mierla 8 anni fa
parent
commit
b05f3637f9
2 ha cambiato i file con 16 aggiunte e 3 eliminazioni
  1. 10 3
      src/modules/cplc/cpl_nonsig.c
  2. 6 0
      src/modules/cplc/cpl_switches.h

+ 10 - 3
src/modules/cplc/cpl_nonsig.c

@@ -230,11 +230,18 @@ void cpl_aux_process( int cmd_out, char *log_dir)
 		LM_ERR("cannot set to IGNORE SIGCHLD signal\n");
 	}
 
+	file[0] = '\0';
+	file_ptr = file;
 	/* set the path for logging */
 	if (log_dir) {
-		strcpy( file, log_dir);
-		file_ptr = file + strlen(log_dir);
-		*(file_ptr++) = '/';
+		if(strlen(log_dir)>=MAX_LOG_DIR_SIZE) {
+			/* fallback */
+			LM_ERR("log dir path is too long, ignoring - check workdir\n");
+		} else {
+			strcpy(file, log_dir);
+			file_ptr = file + strlen(log_dir);
+			*(file_ptr++) = '/';
+		}
 	}
 
 	while(1) {

+ 6 - 0
src/modules/cplc/cpl_switches.h

@@ -873,6 +873,12 @@ inline static int is_lang_tag_matching(str *range,str *cpl_tag,str *cpl_subtag)
 	str tag = {0,0};
 	str subtag = {0,0};
 
+	if(range==NULL || cpl_tag==NULL || cpl_subtag==NULL) {
+		return -1;
+	}
+	if(range->s==NULL || cpl_tag->s==NULL || cpl_subtag->s==NULL) {
+		return -1;
+	}
 	c = range->s;
 	end = range->s + range->len;