samba-vscan/fprot vscan-fprotd_core.c,1.24.2.1,1.24.2.2

[email protected]
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/fprot
In directory sc8-pr-cvs1:/tmp/cvs-serv19342/fprot

Modified Files:
      Tag: VSCAN_0_3
	vscan-fprotd_core.c 
Log Message:
close input/output streams to avoid memory leaks 


Index: vscan-fprotd_core.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/fprot/vscan-fprotd_core.c,v
retrieving revision 1.24.2.1
retrieving revision 1.24.2.2
diff -u -d -r1.24.2.1 -r1.24.2.2
--- vscan-fprotd_core.c	14 Jul 2003 13:09:15 -0000	1.24.2.1
+++ vscan-fprotd_core.c	3 Jan 2004 14:59:41 -0000	1.24.2.2
@@ -130,6 +130,8 @@
 
         fpout = fdopen(sockfd, "w");
         if ( fpout == NULL ) {
+		/* close fpin */
+		fclose(fpin);
                 vscan_syslog("ERROR: Can not open stream for writing - %s", strerror(errno));
                 return -1;
         }
@@ -151,12 +153,18 @@
 
 	if ( fputs(fprotdCommand, fpout) == EOF ) {
 		vscan_syslog("ERROR: can not send file name to F-Prot Daemon!");
+		/* closing streams */
+		fclose(fpout);
+		fclose(fpin);
 		return -1;
 	}
 
 	/* hum, instead of flush()ing, use setvbuf to set to line-buffering? */
         if ( fflush(fpout) == EOF ) {
                 vscan_syslog("ERROR: can not flush output stream - %s", strerror(errno));
+		/* closing streams */
+		fclose(fpout);
+		fclose(fpin);
 		/* better safe than sorry ... */
 		return -1;
         }
@@ -178,11 +186,17 @@
 			if ( strncmp(str, "<name>", 6) == 0 ) {
 				/* virus found */
 				vscan_fprotd_log_virus(scan_file, str, client_ip);
+				/* closing streams */
+				fclose(fpout);
+				fclose(fpin);
 				return 1;
 			} else if ( strncmp(str, "<error>", 7) == 0 ) {
 				/* ERROR */
 				if ( verbose_file_logging )
 					vscan_syslog("ERROR: file %s not found, not readable or an error occured", scan_file);
+				/* closing streams */
+				fclose(fpout);
+				fclose(fpin);
 				return -2;
 			}
 		}
@@ -191,6 +205,9 @@
 	/* did we receive any data from daemon? */
 	if ( !received_data ) {
 		vscan_syslog("ERROR: can not get result from F-Prot Daemon!");
+		/* closing streams */
+		fclose(fpout);
+		fclose(fpin);
 		return -1;
          } else {
 
@@ -198,6 +215,10 @@
 		if ( verbose_file_logging )
         		vscan_syslog("INFO: file %s is clean", scan_file);
 	}
+
+	/* closing streams */
+	fclose(fpout);
+	fclose(fpin);
 
 	return 0;
 }




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.