VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.cpp@ 79767

Last change on this file since 79767 was 79340, checked in by vboxsync, 6 years ago

SharedOpenGL: replaced DATA_POINTER_CHECK with DATA_POINTER_CHECK_SIZE. bugref:9435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.1 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "unpacker.h"
8#include "cr_error.h"
9#include "cr_mem.h"
10#include "state/cr_limits.h"
11
12
13void crUnpackMap2d(PCrUnpackerState pState)
14{
15 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 48, GLint);
16
17 GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
18 GLdouble u1 = READ_DOUBLE(pState, sizeof(int) + 4);
19 GLdouble u2 = READ_DOUBLE(pState, sizeof(int) + 12);
20 GLint ustride = READ_DATA(pState, sizeof(int) + 20, GLint);
21 GLint uorder = READ_DATA(pState, sizeof(int) + 24, GLint);
22 GLdouble v1 = READ_DOUBLE(pState, sizeof(int) + 28);
23 GLdouble v2 = READ_DOUBLE(pState, sizeof(int) + 36);
24 GLint vstride = READ_DATA(pState, sizeof(int) + 44, GLint);
25 GLint vorder = READ_DATA(pState, sizeof(int) + 48, GLint);
26 GLdouble *points = DATA_POINTER(pState, sizeof(int) + 52, GLdouble);
27 GLint cbMax;
28
29 if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
30 vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
31 ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(double) / uorder / 8 ||
32 vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(double) / vorder / 8 )
33 {
34 crError("crUnpackMap2d: parameters out of range");
35 return;
36 }
37
38 cbMax = (ustride * uorder + vstride * vorder) * sizeof(double);
39 if (!DATA_POINTER_CHECK_SIZE(pState, cbMax))
40 {
41 crError("crUnpackMap2d: parameters out of range");
42 return;
43 }
44
45 pState->pDispatchTbl->Map2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
46
47 INCR_VAR_PTR(pState);
48}
49
50void crUnpackMap2f(PCrUnpackerState pState)
51{
52 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 32, GLint);
53
54 GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
55 GLfloat u1 = READ_DATA(pState, sizeof(int) + 4, GLfloat);
56 GLfloat u2 = READ_DATA(pState, sizeof(int) + 8, GLfloat);
57 GLint ustride = READ_DATA(pState, sizeof(int) + 12, GLint);
58 GLint uorder = READ_DATA(pState, sizeof(int) + 16, GLint);
59 GLfloat v1 = READ_DATA(pState, sizeof(int) + 20, GLfloat);
60 GLfloat v2 = READ_DATA(pState, sizeof(int) + 24, GLfloat);
61 GLint vstride = READ_DATA(pState, sizeof(int) + 28, GLint);
62 GLint vorder = READ_DATA(pState, sizeof(int) + 32, GLint);
63 GLfloat *points = DATA_POINTER(pState, sizeof(int) + 36, GLfloat);
64 GLint cbMax;
65
66 if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
67 vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
68 ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(float) / uorder / 8 ||
69 vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(float) / vorder / 8)
70 {
71 crError("crUnpackMap2d: parameters out of range");
72 return;
73 }
74
75 cbMax = (ustride * uorder + vstride * vorder) * sizeof(float);
76 if (!DATA_POINTER_CHECK_SIZE(pState, cbMax))
77 {
78 crError("crUnpackMap2f: parameters out of range");
79 return;
80 }
81
82 pState->pDispatchTbl->Map2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
83
84 INCR_VAR_PTR(pState);
85}
86
87void crUnpackMap1d(PCrUnpackerState pState)
88{
89 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 24, GLint);
90
91 GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
92 GLdouble u1 = READ_DOUBLE(pState, sizeof(int) + 4);
93 GLdouble u2 = READ_DOUBLE(pState, sizeof(int) + 12);
94 GLint stride = READ_DATA(pState, sizeof(int) + 20, GLint);
95 GLint order = READ_DATA(pState, sizeof(int) + 24, GLint);
96 GLdouble *points = DATA_POINTER(pState, sizeof(int) + 28, GLdouble);
97 GLint cbMax;
98
99 if (order < 1 || order > CR_MAX_EVAL_ORDER ||
100 stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(double) / order / 8)
101 {
102 crError("crUnpackMap1d: parameters out of range");
103 return;
104 }
105
106 cbMax = stride * order * sizeof(double);
107 if (!DATA_POINTER_CHECK_SIZE(pState, cbMax))
108 {
109 crError("crUnpackMap1d: parameters out of range");
110 return;
111 }
112
113 pState->pDispatchTbl->Map1d(target, u1, u2, stride, order, points);
114
115 INCR_VAR_PTR(pState);
116}
117
118void crUnpackMap1f(PCrUnpackerState pState)
119{
120 CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 16, GLint);
121
122 GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
123 GLfloat u1 = READ_DATA(pState, sizeof(int) + 4, GLfloat);
124 GLfloat u2 = READ_DATA(pState, sizeof(int) + 8, GLfloat);
125 GLint stride = READ_DATA(pState, sizeof(int) + 12, GLint);
126 GLint order = READ_DATA(pState, sizeof(int) + 16, GLint);
127 GLfloat *points = DATA_POINTER(pState, sizeof(int) + 20, GLfloat);
128 GLint cbMax;
129
130 if (order < 1 || order > CR_MAX_EVAL_ORDER ||
131 stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(float) / order / 8)
132 {
133 crError("crUnpackMap1f: parameters out of range");
134 return;
135 }
136
137 cbMax = stride * order * sizeof(float);
138 if (!DATA_POINTER_CHECK_SIZE(pState, cbMax))
139 {
140 crError("crUnpackMap1f: parameters out of range");
141 return;
142 }
143
144 pState->pDispatchTbl->Map1f(target, u1, u2, stride, order, points);
145 INCR_VAR_PTR(pState);
146}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette