Przeglądaj źródła

port from k r5751, fscanf can fail, fix warning related to recent glibc versions

Henning Westerholt 16 lat temu
rodzic
commit
5dbe4f22dd
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      daemonize.c

+ 6 - 2
daemonize.c

@@ -133,7 +133,9 @@ int daemonize(char*  name)
 	if (pid_file!=0){
 		
 		if ((pid_stream=fopen(pid_file, "r"))!=NULL){
-			fscanf(pid_stream, "%d", &p);
+			if (fscanf(pid_stream, "%d", &p) < 0) {
+				LM_WARN("could not parse pid file %s\n", pid_file);
+			}
 			fclose(pid_stream);
 			if (p==-1){
 				LOG(L_CRIT, "pid file %s exists, but doesn't contain a valid"
@@ -161,7 +163,9 @@ int daemonize(char*  name)
 
 	if (pgid_file!=0){
 		if ((pid_stream=fopen(pgid_file, "r"))!=NULL){
-			fscanf(pid_stream, "%d", &p);
+			if (fscanf(pid_stream, "%d", &p) < 0) {
+				 LM_WARN("could not parse pgid file %s\n", pgid_file);
+			}
 			fclose(pid_stream);
 			if (p==-1){
 				LOG(L_CRIT, "pgid file %s exists, but doesn't contain a valid"