Author: timb
Date: 2008-10-14 22:48:24 +0200 (Tue, 14 Oct 2008)
New Revision: 1545

Modified:
   trunk/openvas-libnasl/ChangeLog
   trunk/openvas-libnasl/nasl/nasl_cmd_exec.c
Log:
Now closes the file descripter and not the pointer to the stream in the NASL 
fread and fwrite functions. Also calls ftruncate() after the file has been 
validated to mimic the previous behaviour of fwrite NASL function. Finally 
fixed a couple of error messages in fwrite which were misleadingly pointing to 
fread NASL function


Modified: trunk/openvas-libnasl/ChangeLog
===================================================================
--- trunk/openvas-libnasl/ChangeLog     2008-10-14 20:21:32 UTC (rev 1544)
+++ trunk/openvas-libnasl/ChangeLog     2008-10-14 20:48:24 UTC (rev 1545)
@@ -1,3 +1,12 @@
+2008-10-14  Tim Brown <[EMAIL PROTECTED]>
+
+       * nasl/nasl_cmd_exec.c: Now closes the file descripter and 
+       not the pointer to the stream in the NASL fread and fwrite
+       functions. Also calls ftruncate() after the file has been
+       validated to mimic the previous behaviour of fwrite NASL
+       function. Finally fixed a couple of error messages in fwrite
+       which were misleadingly pointing to fread NASL function.
+
 2008-10-13  Tim Brown <[EMAIL PROTECTED]>
 
        * nasl/nasl_cmd_exec.c: Fixed logic bug, fdopen returns NULL

Modified: trunk/openvas-libnasl/nasl/nasl_cmd_exec.c
===================================================================
--- trunk/openvas-libnasl/nasl/nasl_cmd_exec.c  2008-10-14 20:21:32 UTC (rev 
1544)
+++ trunk/openvas-libnasl/nasl/nasl_cmd_exec.c  2008-10-14 20:48:24 UTC (rev 
1545)
@@ -278,7 +278,7 @@
   }
   fp = fdopen(fd, "r");
   if (fp == NULL) {
-    close(fp);
+    close(fd);
     nasl_perror(lexic, "fread: %s: %s\n", fname, strerror(errno));
     return NULL;
   }
@@ -399,20 +399,21 @@
     }
     if (fstat(fd, &fstat_info) == -1) {
         close(fd);
-        nasl_perror(lexic, "fread: %s: possible symlink attack!?! %s\n", 
fname, strerror(errno));
+        nasl_perror(lexic, "fwrite: %s: possible symlink attack!?! %s\n", 
fname, strerror(errno));
         return NULL;
     } else {
       if (lstat_info.st_mode != fstat_info.st_mode || lstat_info.st_ino != 
fstat_info.st_ino || lstat_info.st_dev != fstat_info.st_dev) {
         close(fd);
-        nasl_perror(lexic, "fread: %s: possible symlink attack!?!\n", fname);
+        nasl_perror(lexic, "fwrite: %s: possible symlink attack!?!\n", fname);
         return NULL;
       }
     }
   }
+  ftruncate(fd, 0);
   fp = fdopen(fd, "w");
   if (fp == NULL) {
-    close(fp);
-    nasl_perror(lexic, "fread: %s: %s\n", fname, strerror(errno));
+    close(fd);
+    nasl_perror(lexic, "fwrite: %s: %s\n", fname, strerror(errno));
     return NULL;
   }
 

_______________________________________________
Openvas-commits mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits

Reply via email to