]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
add bounds check on OP_ADDRESS
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 24 Aug 2009 05:39:51 +0000 (05:39 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 24 Aug 2009 05:39:51 +0000 (05:39 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9140 d7cf8633-e32d-0410-b094-e92efae38249

prvm_execprogram.h

index 43d047458a5a5f705d3bd5974e1ebadfd7d9ec4d..97bf15d729d5838ca67b65f9fd82a0547be1f09b 100644 (file)
 
                        case OP_ADDRESS:
 #if PRVMBOUNDSCHECK
+                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
+                               {
+                                       prog->xfunction->profile += (st - startst);
+                                       prog->xstatement = st - prog->statements;
+                                       PRVM_ERROR ("%s Progs attempted to address an out of bounds edict number", PRVM_NAME);
+                                       goto cleanup;
+                               }
                                if ((unsigned int)(OPB->_int) >= (unsigned int)(prog->progs->entityfields))
                                {
                                        prog->xfunction->profile += (st - startst);
                        case OP_LOAD_S:
                        case OP_LOAD_FNC:
 #if PRVMBOUNDSCHECK
-                               if (OPA->edict < 0 || OPA->edict >= prog->edictareasize)
+                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
                                {
                                        prog->xfunction->profile += (st - startst);
                                        prog->xstatement = st - prog->statements;
 
                        case OP_LOAD_V:
 #if PRVMBOUNDSCHECK
-                               if (OPA->edict < 0 || OPA->edict >= prog->edictareasize)
+                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
                                {
                                        prog->xfunction->profile += (st - startst);
                                        prog->xstatement = st - prog->statements;
                                break;
                        case OP_LOAD_I:
 #if PRBOUNDSCHECK
-                               if (OPA->edict < 0 || OPA->edict >= pr_edictareasize)
+                               if (OPA->edict < 0 || OPA->edict >= prog->max_edicts)
                                {
                                        prog->xfunction->profile += (st - startst);
                                        prog->xstatement = st - prog->statements;