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

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

Issue 2711783009: [M57] lcms upstream patches to fix security bug (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « third_party/lcms2-2.6/src/cmslut.c ('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-2014 Marti Maria Saguer 4 // Copyright (c) 1998-2014 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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 if (!_cmsReadUInt8Number(io, &InputChannels)) goto Error; 1748 if (!_cmsReadUInt8Number(io, &InputChannels)) goto Error;
1749 if (!_cmsReadUInt8Number(io, &OutputChannels)) goto Error; 1749 if (!_cmsReadUInt8Number(io, &OutputChannels)) goto Error;
1750 if (!_cmsReadUInt8Number(io, &CLUTpoints)) goto Error; 1750 if (!_cmsReadUInt8Number(io, &CLUTpoints)) goto Error;
1751 1751
1752 if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and the n 2 at least 1752 if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and the n 2 at least
1753 1753
1754 // Padding 1754 // Padding
1755 if (!_cmsReadUInt8Number(io, NULL)) goto Error; 1755 if (!_cmsReadUInt8Number(io, NULL)) goto Error;
1756 1756
1757 // Do some checking 1757 // Do some checking
1758 if (InputChannels > cmsMAXCHANNELS) goto Error; 1758 if (InputChannels == 0 || InputChannels > cmsMAXCHANNELS) goto Error;
1759 if (OutputChannels > cmsMAXCHANNELS) goto Error; 1759 if (OutputChannels == 0 || OutputChannels > cmsMAXCHANNELS) goto Error;
1760 1760
1761 // Allocates an empty Pipeline 1761 // Allocates an empty Pipeline
1762 NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels); 1762 NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);
1763 if (NewLUT == NULL) goto Error; 1763 if (NewLUT == NULL) goto Error;
1764 1764
1765 // Read the Matrix 1765 // Read the Matrix
1766 if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error; 1766 if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error;
1767 if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error; 1767 if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error;
1768 if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error; 1768 if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error;
1769 if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error; 1769 if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 *nItems = 0; 2041 *nItems = 0;
2042 2042
2043 if (!_cmsReadUInt8Number(io, &InputChannels)) return NULL; 2043 if (!_cmsReadUInt8Number(io, &InputChannels)) return NULL;
2044 if (!_cmsReadUInt8Number(io, &OutputChannels)) return NULL; 2044 if (!_cmsReadUInt8Number(io, &OutputChannels)) return NULL;
2045 if (!_cmsReadUInt8Number(io, &CLUTpoints)) return NULL; // 255 maximum 2045 if (!_cmsReadUInt8Number(io, &CLUTpoints)) return NULL; // 255 maximum
2046 2046
2047 // Padding 2047 // Padding
2048 if (!_cmsReadUInt8Number(io, NULL)) return NULL; 2048 if (!_cmsReadUInt8Number(io, NULL)) return NULL;
2049 2049
2050 // Do some checking 2050 // Do some checking
2051 if (InputChannels > cmsMAXCHANNELS) goto Error; 2051 if (InputChannels == 0 || InputChannels > cmsMAXCHANNELS) goto Error;
2052 if (OutputChannels > cmsMAXCHANNELS) goto Error; 2052 if (OutputChannels == 0 || OutputChannels > cmsMAXCHANNELS) goto Error;
2053 2053
2054 // Allocates an empty LUT 2054 // Allocates an empty LUT
2055 NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels); 2055 NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);
2056 if (NewLUT == NULL) goto Error; 2056 if (NewLUT == NULL) goto Error;
2057 2057
2058 // Read the Matrix 2058 // Read the Matrix
2059 if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error; 2059 if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error;
2060 if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error; 2060 if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error;
2061 if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error; 2061 if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error;
2062 if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error; 2062 if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 if (!_cmsReadUInt8Number(io, &outputChan)) return NULL; 2479 if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
2480 2480
2481 if (!_cmsReadUInt16Number(io, NULL)) return NULL; 2481 if (!_cmsReadUInt16Number(io, NULL)) return NULL;
2482 2482
2483 if (!_cmsReadUInt32Number(io, &offsetB)) return NULL; 2483 if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
2484 if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL; 2484 if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
2485 if (!_cmsReadUInt32Number(io, &offsetM)) return NULL; 2485 if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
2486 if (!_cmsReadUInt32Number(io, &offsetC)) return NULL; 2486 if (!_cmsReadUInt32Number(io, &offsetC)) return NULL;
2487 if (!_cmsReadUInt32Number(io, &offsetA)) return NULL; 2487 if (!_cmsReadUInt32Number(io, &offsetA)) return NULL;
2488 2488
2489 // Allocates an empty LUT 2489 if (inputChan == 0 || inputChan >= cmsMAXCHANNELS) return NULL;
2490 if (outputChan == 0 || outputChan >= cmsMAXCHANNELS) return NULL;
2491
2492 // Allocates an empty LUT
2490 NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan); 2493 NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan);
2491 if (NewLUT == NULL) return NULL; 2494 if (NewLUT == NULL) return NULL;
2492 2495
2493 if (offsetA!= 0) { 2496 if (offsetA!= 0) {
2494 if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetA, inputChan))) 2497 if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetA, inputChan)))
2495 goto Error; 2498 goto Error;
2496 } 2499 }
2497 2500
2498 if (offsetC != 0) { 2501 if (offsetC != 0) {
2499 if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadCLUT(self, io, BaseOf fset + offsetC, inputChan, outputChan))) 2502 if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadCLUT(self, io, BaseOf fset + offsetC, inputChan, outputChan)))
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 cmsUInt32Number offsetC; // Offset to CLUT 2790 cmsUInt32Number offsetC; // Offset to CLUT
2788 cmsUInt32Number offsetA; // Offset to first "A" curve 2791 cmsUInt32Number offsetA; // Offset to first "A" curve
2789 cmsPipeline* NewLUT = NULL; 2792 cmsPipeline* NewLUT = NULL;
2790 2793
2791 2794
2792 BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase); 2795 BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
2793 2796
2794 if (!_cmsReadUInt8Number(io, &inputChan)) return NULL; 2797 if (!_cmsReadUInt8Number(io, &inputChan)) return NULL;
2795 if (!_cmsReadUInt8Number(io, &outputChan)) return NULL; 2798 if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
2796 2799
2800 if (inputChan == 0 || inputChan >= cmsMAXCHANNELS) return NULL;
2801 if (outputChan == 0 || outputChan >= cmsMAXCHANNELS) return NULL;
2802
2797 // Padding 2803 // Padding
2798 if (!_cmsReadUInt16Number(io, NULL)) return NULL; 2804 if (!_cmsReadUInt16Number(io, NULL)) return NULL;
2799 2805
2800 if (!_cmsReadUInt32Number(io, &offsetB)) return NULL; 2806 if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
2801 if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL; 2807 if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
2802 if (!_cmsReadUInt32Number(io, &offsetM)) return NULL; 2808 if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
2803 if (!_cmsReadUInt32Number(io, &offsetC)) return NULL; 2809 if (!_cmsReadUInt32Number(io, &offsetC)) return NULL;
2804 if (!_cmsReadUInt32Number(io, &offsetA)) return NULL; 2810 if (!_cmsReadUInt32Number(io, &offsetA)) return NULL;
2805 2811
2806 // Allocates an empty LUT 2812 // Allocates an empty LUT
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
4436 cmsPipeline *NewLUT = NULL; 4442 cmsPipeline *NewLUT = NULL;
4437 cmsUInt32Number BaseOffset; 4443 cmsUInt32Number BaseOffset;
4438 4444
4439 // Get actual position as a basis for element offsets 4445 // Get actual position as a basis for element offsets
4440 BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase); 4446 BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
4441 4447
4442 // Read channels and element count 4448 // Read channels and element count
4443 if (!_cmsReadUInt16Number(io, &InputChans)) return NULL; 4449 if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
4444 if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL; 4450 if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
4445 4451
4452 if (InputChans == 0 || InputChans >= cmsMAXCHANNELS) return NULL;
4453 if (OutputChans == 0 || OutputChans >= cmsMAXCHANNELS) return NULL;
4454
4446 // Allocates an empty LUT 4455 // Allocates an empty LUT
4447 NewLUT = cmsPipelineAlloc(self ->ContextID, InputChans, OutputChans); 4456 NewLUT = cmsPipelineAlloc(self ->ContextID, InputChans, OutputChans);
4448 if (NewLUT == NULL) return NULL; 4457 if (NewLUT == NULL) return NULL;
4449 4458
4450 if (!_cmsReadUInt32Number(io, &ElementCount)) return NULL; 4459 if (!_cmsReadUInt32Number(io, &ElementCount)) return NULL;
4451 4460
4452 if (!ReadPositionTable(self, io, ElementCount, BaseOffset, NewLUT, ReadMPEEl em)) { 4461 if (!ReadPositionTable(self, io, ElementCount, BaseOffset, NewLUT, ReadMPEEl em)) {
4453 if (NewLUT != NULL) cmsPipelineFree(NewLUT); 4462 if (NewLUT != NULL) cmsPipelineFree(NewLUT);
4454 *nItems = 0; 4463 *nItems = 0;
4455 return NULL; 4464 return NULL;
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5581 5590
5582 for (pt = SupportedTags; 5591 for (pt = SupportedTags;
5583 pt != NULL; 5592 pt != NULL;
5584 pt = pt ->Next) { 5593 pt = pt ->Next) {
5585 5594
5586 if (sig == pt -> Signature) return &pt ->Descriptor; 5595 if (sig == pt -> Signature) return &pt ->Descriptor;
5587 } 5596 }
5588 5597
5589 return NULL; 5598 return NULL;
5590 } 5599 }
OLDNEW
« no previous file with comments | « third_party/lcms2-2.6/src/cmslut.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698