commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r801741 - in /commons/sandbox/runtime/trunk/src/main/native/os/unix: execmem.c shm.c
Date Thu, 06 Aug 2009 17:41:33 GMT
Author: mturk
Date: Thu Aug  6 17:41:33 2009
New Revision: 801741

URL: http://svn.apache.org/viewvc?rev=801741&view=rev
Log:
Check provided param values for sanity

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c?rev=801741&r1=801740&r2=801741&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c Thu Aug  6 17:41:33 2009
@@ -61,6 +61,11 @@
     acr_size_t ass = (acr_size_t)ACR_ALIGN(siz, acr_page_size);
 
     UNREFERENCED_O;
+    if (ass < (acr_size_t)siz) {
+        /* Guard against faulty align value */
+        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
+        return NULL;
+    }
 #ifdef ACR_USE_MMAP
     mem = mmap(0, ass, PROT_READ | PROT_WRITE | PROT_EXEC,
                MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c?rev=801741&r1=801740&r2=801741&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c Thu Aug  6 17:41:33 2009
@@ -220,6 +220,14 @@
     int         rc;
     acr_size_t  nbytes;
 
+    if (reqsize > ACR_SIZE_T_MAX) {
+        /* Guard against insane sizes */
+        if (!IS_INVALID_HANDLE(_E)) {
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
+        }
+        ACR_SET_OS_ERROR(ACR_EINVAL);
+        return -1;
+    }
     shm = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_shm_t));
     if (!shm)
         return -1;



Mime
View raw message