diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2024-09-29 20:38:00 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2024-09-29 20:38:00 +0000 |
commit | bb6a16b2b40d3f34e79d7101e1bab8a9a7be8eff (patch) | |
tree | a81beb5fc62fe4eee63e347edc3ed51b81a0abb2 | |
parent | d746389c3036e5e18ed061e933d64ad2b1038427 (diff) | |
download | netpbm-mirror-super_stable.tar.gz netpbm-mirror-super_stable.tar.xz netpbm-mirror-super_stable.zip |
Release 10.86.43 super_stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@4952 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | doc/HISTORY | 10 | ||||
-rw-r--r-- | lib/libpamcolor.c | 37 | ||||
-rw-r--r-- | version.mk | 2 |
3 files changed, 42 insertions, 7 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index 4baa7609..65c9c0b6 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,16 @@ Netpbm. CHANGE HISTORY -------------- +24.09.29 BJH Release 10.86.43 + + libnetpbm color name parsing: Fix handling of rgb: color names + with more than 4 hex digits per plane, so it throws an error + instead of generating an invalid or wrong color. Broken in + primordial Netpbm. + + libnetpbm color name parsing: Fix error message for invalid + rgb-<MAXVAL> color name. + 24.06.28 BJH Release 10.86.42 libnetpbm: Fix double free crash when memory allocation via diff --git a/lib/libpamcolor.c b/lib/libpamcolor.c index 39ff793b..5bb9f5c8 100644 --- a/lib/libpamcolor.c +++ b/lib/libpamcolor.c @@ -61,25 +61,50 @@ parseHexDigits(const char * const string, char const delim, samplen * const nP, unsigned int * const digitCtP) { +/*---------------------------------------------------------------------------- + Parse the hexadecimal sample value (e.g. "3fff") which is the first + character of ASCIIZ string 'string' up to the first instance of 'delim'. + + Return its value as a normalized sample value as *nP and the number of + hexadecimal digits given as *digitCtP. + + E.g. if 'string' is "10/abc" and 'delim' is '/', we return *nP == 16/255 + and *digitCtP == 2. + Abort program if the delimeter does not appear in 'string' or there are no + digits before the delimiter or there are more than 4 (it's supposed to be a + sample value, so +-----------------------------------------------------------------------------*/ unsigned int digitCt; + /* Number of digits of 'string' we've processed so far */ unsigned long n; + /* Numerical value of 'string' if it were to stop after 'digitCt' + digits + */ unsigned long range; /* 16 for one hex digit, 256 for two hex digits, etc. */ - for (digitCt = 0, n = 0, range = 1; string[digitCt] != delim; ) { + const char * error; + + for (digitCt = 0, n = 0, range = 1, error = NULL; + !error && string[digitCt] != delim; ) { char const digit = string[digitCt]; if (digit == '\0') - pm_error("rgb: color spec '%s' ends prematurely", string); + error = "Ends prematurely"; else { + if (digitCt >= 4) + error = "Too many digits. " + "Max allowed for a Netpbm sample value is 4. "; n = n * 16 + hexDigitValue(digit); range *= 16; ++digitCt; } } - if (range <= 1) - pm_error("No digits where hexadecimal number expected in rgb: " - "color spec '%s'", string); + if (!error && range <= 1) + error = "No digits where hexadecimal number expected"; + + if (error) + pm_error("Invalid rgb: color spec '%s'. %s", string, error); *nP = (samplen) n / (range-1); *digitCtP = digitCt; @@ -164,7 +189,7 @@ parseInteger(const char * const colorname, if (rc != 4) pm_error("invalid color specifier '%s'. " "If it starts with \"rgb-\", then it must have the format " - "rgb-<MAXVAL>:<RED>:<GRN>:<BLU>, " + "rgb-<MAXVAL>/<RED>/<GRN>/<BLU>, " "where <MAXVAL>, <RED>, <GRN>, and <BLU> are " "unsigned integers", colorname); diff --git a/version.mk b/version.mk index 0d42aef6..6115ee71 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 86 -NETPBM_POINT_RELEASE = 42 +NETPBM_POINT_RELEASE = 43 |