Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mm2/Little-CMS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <marti.maria@littlecms.com>2022-08-29 17:57:20 +0300
committerMarti Maria <marti.maria@littlecms.com>2022-08-29 17:57:20 +0300
commit6e929aacd463fecda095fad7489fd1c0056de343 (patch)
tree68b6da004bb08f9ccbad323416a6547f95b61d65
parent4a3cedac2f8b5b12caa42fac992baad7343883ae (diff)
A better checker for ascii to int conversion
People keeps trying to break tools helper code, so let's put guards.
-rw-r--r--src/cmscgats.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cmscgats.c b/src/cmscgats.c
index 1b96456..0c986e9 100644
--- a/src/cmscgats.c
+++ b/src/cmscgats.c
@@ -1528,7 +1528,7 @@ void AllocateDataFormat(cmsIT8* it8)
if (t -> DataFormat) return; // Already allocated
- t -> nSamples = (int) cmsIT8GetPropertyDbl(it8, "NUMBER_OF_FIELDS");
+ t -> nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
if (t -> nSamples <= 0) {
@@ -1586,8 +1586,15 @@ cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE h, int n, const char *Sample)
static
cmsInt32Number satoi(const char* b)
{
+ int n;
+
if (b == NULL) return 0;
- return atoi(b);
+
+ n = atoi(b);
+ if (n > 0x7fffffffL) return 0x7fffffffL;
+ if (n < -0x7ffffffeL) return -0x7ffffffeL;
+
+ return (cmsInt32Number)n;
}
// Convert to binary