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

Side by Side Diff: third_party/lcms2-2.6/src/cmsplugin.c

Issue 2577963007: lcms: Sanitize floating point read (Closed)
Patch Set: lcms: Sanitize floating point read Created 4 years 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
« no previous file with comments | « third_party/lcms2-2.6/README.pdfium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //------------------------------------------------------------------------------ --- 1 //------------------------------------------------------------------------------ ---
2 // 2 //
3 // Little Color Management System 3 // Little Color Management System
4 // Copyright (c) 1998-2010 Marti Maria Saguer 4 // Copyright (c) 1998-2010 Marti Maria Saguer
5 // 5 //
6 // Permission is hereby granted, free of charge, to any person obtaining 6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"), 7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation 8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (io -> Read(io, &tmp, sizeof(cmsFloat32Number), 1) != 1) 175 if (io -> Read(io, &tmp, sizeof(cmsFloat32Number), 1) != 1)
176 return FALSE; 176 return FALSE;
177 177
178 if (n != NULL) { 178 if (n != NULL) {
179 179
180 tmp = _cmsAdjustEndianess32(tmp); 180 tmp = _cmsAdjustEndianess32(tmp);
181 *n = *(cmsFloat32Number*) &tmp; 181 *n = *(cmsFloat32Number*) &tmp;
182 if (isnan(*n)) 182 if (isnan(*n))
183 return FALSE; 183 return FALSE;
184 } 184 }
185 return TRUE; 185
186 // fpclassify() required by C99
187 return ((fpclassify(*n) == FP_ZERO) || (fpclassify(*n) == FP_NORMAL));
Tom Sepez 2016/12/16 18:27:34 nit: overparenthesized (2 levels).
kcwu 2016/12/17 03:32:06 Done.
186 } 188 }
187 189
188 190
189 cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n) 191 cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n)
190 { 192 {
191 cmsUInt64Number tmp; 193 cmsUInt64Number tmp;
192 194
193 _cmsAssert(io != NULL); 195 _cmsAssert(io != NULL);
194 196
195 if (io -> Read(io, &tmp, sizeof(cmsUInt64Number), 1) != 1) 197 if (io -> Read(io, &tmp, sizeof(cmsUInt64Number), 1) != 1)
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 // free the memory block itself 950 // free the memory block itself
949 _cmsFree(&fakeContext, ctx); 951 _cmsFree(&fakeContext, ctx);
950 } 952 }
951 } 953 }
952 954
953 // Returns the user data associated to the given ContextID, or NULL if no user d ata was attached on context creation 955 // Returns the user data associated to the given ContextID, or NULL if no user d ata was attached on context creation
954 void* CMSEXPORT cmsGetContextUserData(cmsContext ContextID) 956 void* CMSEXPORT cmsGetContextUserData(cmsContext ContextID)
955 { 957 {
956 return _cmsContextGetClientChunk(ContextID, UserPtr); 958 return _cmsContextGetClientChunk(ContextID, UserPtr);
957 } 959 }
OLDNEW
« no previous file with comments | « third_party/lcms2-2.6/README.pdfium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698