VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c@ 76787

最後變更 在這個檔案從76787是 76787,由 vboxsync 提交於 6 年 前

3D: Parameters validation corrected, bugref:9327

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 4.4 KB
 
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(void)
14{
15 GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
16 GLdouble u1 = READ_DOUBLE(sizeof(int) + 4);
17 GLdouble u2 = READ_DOUBLE(sizeof(int) + 12);
18 GLint ustride = READ_DATA(sizeof(int) + 20, GLint);
19 GLint uorder = READ_DATA(sizeof(int) + 24, GLint);
20 GLdouble v1 = READ_DOUBLE(sizeof(int) + 28);
21 GLdouble v2 = READ_DOUBLE(sizeof(int) + 36);
22 GLint vstride = READ_DATA(sizeof(int) + 44, GLint);
23 GLint vorder = READ_DATA(sizeof(int) + 48, GLint);
24 GLdouble *points = DATA_POINTER(sizeof(int) + 52, GLdouble);
25 GLint cbMax;
26
27 if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
28 vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
29 ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(double) / uorder / 8 ||
30 vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(double) / vorder / 8 )
31 {
32 crError("crUnpackMap2d: parameters out of range");
33 return;
34 }
35
36 cbMax = (ustride * uorder + vstride * vorder) * sizeof(double);
37 if (!DATA_POINTER_CHECK(cbMax))
38 {
39 crError("crUnpackMap2d: parameters out of range");
40 return;
41 }
42
43 cr_unpackDispatch.Map2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
44
45 INCR_VAR_PTR();
46}
47
48void crUnpackMap2f(void)
49{
50 GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
51 GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat);
52 GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat);
53 GLint ustride = READ_DATA(sizeof(int) + 12, GLint);
54 GLint uorder = READ_DATA(sizeof(int) + 16, GLint);
55 GLfloat v1 = READ_DATA(sizeof(int) + 20, GLfloat);
56 GLfloat v2 = READ_DATA(sizeof(int) + 24, GLfloat);
57 GLint vstride = READ_DATA(sizeof(int) + 28, GLint);
58 GLint vorder = READ_DATA(sizeof(int) + 32, GLint);
59 GLfloat *points = DATA_POINTER(sizeof(int) + 36, GLfloat);
60 GLint cbMax;
61
62 if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
63 vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
64 ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(float) / uorder / 8 ||
65 vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(float) / vorder / 8)
66 {
67 crError("crUnpackMap2d: parameters out of range");
68 return;
69 }
70
71 cbMax = (ustride * uorder + vstride * vorder) * sizeof(float);
72 if (!DATA_POINTER_CHECK(cbMax))
73 {
74 crError("crUnpackMap2f: parameters out of range");
75 return;
76 }
77
78 cr_unpackDispatch.Map2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
79
80 INCR_VAR_PTR();
81}
82
83void crUnpackMap1d(void)
84{
85 GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
86 GLdouble u1 = READ_DOUBLE(sizeof(int) + 4);
87 GLdouble u2 = READ_DOUBLE(sizeof(int) + 12);
88 GLint stride = READ_DATA(sizeof(int) + 20, GLint);
89 GLint order = READ_DATA(sizeof(int) + 24, GLint);
90 GLdouble *points = DATA_POINTER(sizeof(int) + 28, GLdouble);
91 GLint cbMax;
92
93 if (order < 1 || order > CR_MAX_EVAL_ORDER ||
94 stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(double) / order / 8)
95 {
96 crError("crUnpackMap1d: parameters out of range");
97 return;
98 }
99
100 cbMax = stride * order * sizeof(double);
101 if (!DATA_POINTER_CHECK(cbMax))
102 {
103 crError("crUnpackMap1d: parameters out of range");
104 return;
105 }
106
107 cr_unpackDispatch.Map1d(target, u1, u2, stride, order, points);
108
109 INCR_VAR_PTR();
110}
111
112void crUnpackMap1f(void)
113{
114 GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
115 GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat);
116 GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat);
117 GLint stride = READ_DATA(sizeof(int) + 12, GLint);
118 GLint order = READ_DATA(sizeof(int) + 16, GLint);
119 GLfloat *points = DATA_POINTER(sizeof(int) + 20, GLfloat);
120 GLint cbMax;
121
122 if (order < 1 || order > CR_MAX_EVAL_ORDER ||
123 stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(float) / order / 8)
124 {
125 crError("crUnpackMap1f: parameters out of range");
126 return;
127 }
128
129 cbMax = stride * order * sizeof(float);
130 if (!DATA_POINTER_CHECK(cbMax))
131 {
132 crError("crUnpackMap1f: parameters out of range");
133 return;
134 }
135
136 cr_unpackDispatch.Map1f(target, u1, u2, stride, order, points);
137 INCR_VAR_PTR();
138}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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