Don't allow zero length files to be exec'd (causes a panic after it is
[unix-history] / sys / kern / kern_execve.c
index 5fbdeb6..1d712e2 100644 (file)
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     $Id: kern_execve.c,v 1.12 1993/12/20 19:31:17 wollman Exp $
+ *     $Id: kern_execve.c,v 1.13 1994/01/03 07:56:43 davidg Exp $
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -498,6 +498,12 @@ exec_check_permissions(iparams)
                return (EACCES);
        }
 
                return (EACCES);
        }
 
+       /*
+        * Zero length files can't be exec'd
+        */
+       if (attr->va_size == 0)
+               return (ENOEXEC);
+
        /*
         * Disable setuid/setgid if the filesystem prohibits it or if
         *      the process is being traced.
        /*
         * Disable setuid/setgid if the filesystem prohibits it or if
         *      the process is being traced.