Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/qcms/google.patch

Issue 363593004: Check for unused tag_len in read_nested_curveType() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/qcms/README.chromium ('k') | third_party/qcms/src/iccread.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff --git a/third_party/qcms/src/iccread.c b/third_party/qcms/src/iccread.c 1 diff --git a/third_party/qcms/src/iccread.c b/third_party/qcms/src/iccread.c
2 index 36b7011..9ee6b94 100644 2 index 36b7011..5876f96 100644
3 --- a/third_party/qcms/src/iccread.c 3 --- a/third_party/qcms/src/iccread.c
4 +++ b/third_party/qcms/src/iccread.c 4 +++ b/third_party/qcms/src/iccread.c
5 @@ -266,7 +266,7 @@ qcms_bool qcms_profile_is_bogus(qcms_profile *profile) 5 @@ -266,7 +266,7 @@ qcms_bool qcms_profile_is_bogus(qcms_profile *profile)
6 if (profile->color_space != RGB_SIGNATURE) 6 if (profile->color_space != RGB_SIGNATURE)
7 return false; 7 return false;
8 8
9 - if (profile->A2B0 || profile->B2A0) 9 - if (profile->A2B0 || profile->B2A0)
10 + if (qcms_supports_iccv4 && (profile->A2B0 || profile->B2A0)) 10 + if (qcms_supports_iccv4 && (profile->A2B0 || profile->B2A0))
11 return false; 11 return false;
12 12
(...skipping 23 matching lines...) Expand all
36 if (!(((sum[i] - tolerance[i]) <= target[i]) && 36 if (!(((sum[i] - tolerance[i]) <= target[i]) &&
37 @@ -402,7 +411,7 @@ static struct XYZNumber read_tag_XYZType(struct mem_source * src, struct tag_inde 37 @@ -402,7 +411,7 @@ static struct XYZNumber read_tag_XYZType(struct mem_source * src, struct tag_inde
38 // present that are not part of the tag_index. 38 // present that are not part of the tag_index.
39 static struct curveType *read_curveType(struct mem_source *src, uint32_t offset , uint32_t *len) 39 static struct curveType *read_curveType(struct mem_source *src, uint32_t offset , uint32_t *len)
40 { 40 {
41 - static const size_t COUNT_TO_LENGTH[5] = {1, 3, 4, 5, 7}; 41 - static const size_t COUNT_TO_LENGTH[5] = {1, 3, 4, 5, 7};
42 + static const uint32_t COUNT_TO_LENGTH[5] = {1, 3, 4, 5, 7}; 42 + static const uint32_t COUNT_TO_LENGTH[5] = {1, 3, 4, 5, 7};
43 struct curveType *curve = NULL; 43 struct curveType *curve = NULL;
44 uint32_t type = read_u32(src, offset); 44 uint32_t type = read_u32(src, offset);
45 uint32_t count; 45 uint32_t count;
46 @@ -657,7 +666,7 @@ static struct lutType *read_tag_lutType(struct mem_source *s rc, struct tag_index 46 @@ -484,19 +493,23 @@ static void read_nested_curveType(struct mem_source *src, struct curveType *(*cu
47 » uint32_t channel_offset = 0;
48 » int i;
49 » for (i = 0; i < num_channels; i++) {
50 -» » uint32_t tag_len;
51 +» » uint32_t tag_len = ~0;
52
53 » » (*curveArray)[i] = read_curveType(src, curve_offset + channel_of fset, &tag_len);
54 » » if (!(*curveArray)[i]) {
55 » » » invalid_source(src, "invalid nested curveType curve");
56 » » }
57
58 +» » if (tag_len == ~0) {
59 +» » » invalid_source(src, "invalid nested curveType tag length ");
60 +» » » return;
61 +» » }
62 +
63 » » channel_offset += tag_len;
64 » » // 4 byte aligned
65 » » if ((tag_len % 4) != 0)
66 » » » channel_offset += 4 - (tag_len % 4);
67 » }
68 -
69 }
70
71 static void mAB_release(struct lutmABType *lut)
72 @@ -657,7 +670,7 @@ static struct lutType *read_tag_lutType(struct mem_source *s rc, struct tag_index
47 uint16_t num_input_table_entries; 73 uint16_t num_input_table_entries;
48 uint16_t num_output_table_entries; 74 uint16_t num_output_table_entries;
49 uint8_t in_chan, grid_points, out_chan; 75 uint8_t in_chan, grid_points, out_chan;
50 - uint32_t clut_offset, output_offset; 76 - uint32_t clut_offset, output_offset;
51 + size_t clut_offset, output_offset; 77 + size_t clut_offset, output_offset;
52 uint32_t clut_size; 78 uint32_t clut_size;
53 size_t entry_size; 79 size_t entry_size;
54 struct lutType *lut; 80 struct lutType *lut;
55 @@ -997,6 +1006,9 @@ qcms_profile* qcms_profile_from_memory(const void *mem, siz e_t size) 81 @@ -997,6 +1010,9 @@ qcms_profile* qcms_profile_from_memory(const void *mem, siz e_t size)
56 source.size = size; 82 source.size = size;
57 source.valid = true; 83 source.valid = true;
58 84
59 + if (size < 4) 85 + if (size < 4)
60 + return INVALID_PROFILE; 86 + return INVALID_PROFILE;
61 + 87 +
62 length = read_u32(src, 0); 88 length = read_u32(src, 0);
63 if (length <= size) { 89 if (length <= size) {
64 // shrink the area that we can read if appropriate 90 // shrink the area that we can read if appropriate
65 diff --git a/third_party/qcms/src/qcms.h b/third_party/qcms/src/qcms.h 91 diff --git a/third_party/qcms/src/qcms.h b/third_party/qcms/src/qcms.h
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1027
1002 -float lut_interp_linear(double value, uint16_t *table, int length); 1028 -float lut_interp_linear(double value, uint16_t *table, int length);
1003 -float lut_interp_linear_float(float value, float *table, int length); 1029 -float lut_interp_linear_float(float value, float *table, int length);
1004 -uint16_t lut_interp_linear16(uint16_t input_value, uint16_t *table, int length) ; 1030 -uint16_t lut_interp_linear16(uint16_t input_value, uint16_t *table, int length) ;
1005 +float lut_interp_linear(double value, uint16_t *table, size_t length); 1031 +float lut_interp_linear(double value, uint16_t *table, size_t length);
1006 +float lut_interp_linear_float(float value, float *table, size_t length); 1032 +float lut_interp_linear_float(float value, float *table, size_t length);
1007 +uint16_t lut_interp_linear16(uint16_t input_value, uint16_t *table, size_t leng th); 1033 +uint16_t lut_interp_linear16(uint16_t input_value, uint16_t *table, size_t leng th);
1008 1034
1009 1035
1010 static inline float lerp(float a, float b, float t) 1036 static inline float lerp(float a, float b, float t)
OLDNEW
« no previous file with comments | « third_party/qcms/README.chromium ('k') | third_party/qcms/src/iccread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698