diff options
author | Scott Revelt <scott.revelt@sun.com> | 2006-06-16 19:11:13 -0700 |
---|---|---|
committer | Donnie Berkholz <spyderous@gentoo.org> | 2006-06-22 15:28:14 -0700 |
commit | 5bbd0822c5a926de0ed293437fb9f2b75cf3c4f4 (patch) | |
tree | 6676c0b8c4bad19734a7d7dbf08301924e8c2405 | |
parent | 0b05cd4da6134df527fb010384a9fd569bd5d6a3 (diff) | |
download | xorg-lib-libX11-5bbd0822c5a926de0ed293437fb9f2b75cf3c4f4.tar.gz |
Sun bug 4022903: Xcms routines may fail if sscanf() is looking for separators
based on locale that doesn't match those used in the Xcms.txt
(cherry picked from 94f3213fc4bd6ec49bfb68e8b4a4fddea2bf3baa commit)
-rw-r--r-- | src/xcms/HVC.c | 19 | ||||
-rw-r--r-- | src/xcms/LRGB.c | 19 | ||||
-rw-r--r-- | src/xcms/Lab.c | 19 | ||||
-rw-r--r-- | src/xcms/Luv.c | 17 | ||||
-rw-r--r-- | src/xcms/XYZ.c | 19 | ||||
-rw-r--r-- | src/xcms/uvY.c | 19 | ||||
-rw-r--r-- | src/xcms/xyY.c | 19 |
7 files changed, 125 insertions, 6 deletions
diff --git a/src/xcms/HVC.c b/src/xcms/HVC.c index 80942623..b57e7291 100644 --- a/src/xcms/HVC.c +++ b/src/xcms/HVC.c @@ -201,7 +201,24 @@ TekHVC_ParseString( &pColor->spec.TekHVC.H, &pColor->spec.TekHVC.V, &pColor->spec.TekHVC.C) != 3) { - return(XcmsFailure); + char *s; /* Maybe failed due to locale */ + int f; + if ((s = strdup(spec))) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.TekHVC.H, + &pColor->spec.TekHVC.V, + &pColor->spec.TekHVC.C) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else + return(XcmsFailure); } pColor->format = XcmsTekHVCFormat; pColor->pixel = 0; diff --git a/src/xcms/LRGB.c b/src/xcms/LRGB.c index e4bc0b50..bf8cacd7 100644 --- a/src/xcms/LRGB.c +++ b/src/xcms/LRGB.c @@ -1432,7 +1432,24 @@ XcmsLRGB_RGBi_ParseString( &pColor->spec.RGBi.red, &pColor->spec.RGBi.green, &pColor->spec.RGBi.blue) != 3) { - return(XcmsFailure); + char *s; /* Maybe failed due to locale */ + int f; + if (s = strdup(spec)) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.RGBi.red, + &pColor->spec.RGBi.green, + &pColor->spec.RGBi.blue) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else + return(XcmsFailure); } /* diff --git a/src/xcms/Lab.c b/src/xcms/Lab.c index 596c137f..7238c164 100644 --- a/src/xcms/Lab.c +++ b/src/xcms/Lab.c @@ -162,7 +162,24 @@ CIELab_ParseString( &pColor->spec.CIELab.L_star, &pColor->spec.CIELab.a_star, &pColor->spec.CIELab.b_star) != 3) { - return(XcmsFailure); + char *s; /* Maybe failed due to locale */ + int f; + if (s = strdup(spec)) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.CIELab.L_star, + &pColor->spec.CIELab.a_star, + &pColor->spec.CIELab.b_star) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else + return(XcmsFailure); } pColor->format = XcmsCIELabFormat; pColor->pixel = 0; diff --git a/src/xcms/Luv.c b/src/xcms/Luv.c index ec94c9e5..3af891af 100644 --- a/src/xcms/Luv.c +++ b/src/xcms/Luv.c @@ -165,6 +165,23 @@ CIELuv_ParseString( &pColor->spec.CIELuv.L_star, &pColor->spec.CIELuv.u_star, &pColor->spec.CIELuv.v_star) != 3) { + char *s; /* Maybe failed due to locale */ + int f; + if (s = strdup(spec)) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.CIELuv.L_star, + &pColor->spec.CIELuv.u_star, + &pColor->spec.CIELuv.v_star) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else return(XcmsFailure); } pColor->format = XcmsCIELuvFormat; diff --git a/src/xcms/XYZ.c b/src/xcms/XYZ.c index f5f17f35..b4dda774 100644 --- a/src/xcms/XYZ.c +++ b/src/xcms/XYZ.c @@ -144,7 +144,24 @@ CIEXYZ_ParseString( &pColor->spec.CIEXYZ.X, &pColor->spec.CIEXYZ.Y, &pColor->spec.CIEXYZ.Z) != 3) { - return(XcmsFailure); + char *s; /* Maybe failed due to locale */ + int f; + if (s = strdup(spec)) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.CIEXYZ.X, + &pColor->spec.CIEXYZ.Y, + &pColor->spec.CIEXYZ.Z) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else + return(XcmsFailure); } pColor->format = XcmsCIEXYZFormat; pColor->pixel = 0; diff --git a/src/xcms/uvY.c b/src/xcms/uvY.c index d7c3e6ab..28b1ecb1 100644 --- a/src/xcms/uvY.c +++ b/src/xcms/uvY.c @@ -159,7 +159,24 @@ CIEuvY_ParseString( &pColor->spec.CIEuvY.u_prime, &pColor->spec.CIEuvY.v_prime, &pColor->spec.CIEuvY.Y) != 3) { - return(XcmsFailure); + char *s; /* Maybe failed due to locale */ + int f; + if (s = strdup(spec)) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.CIEuvY.u_prime, + &pColor->spec.CIEuvY.v_prime, + &pColor->spec.CIEuvY.Y) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else + return(XcmsFailure); } pColor->format = XcmsCIEuvYFormat; pColor->pixel = 0; diff --git a/src/xcms/xyY.c b/src/xcms/xyY.c index 63e80bc5..81e681b4 100644 --- a/src/xcms/xyY.c +++ b/src/xcms/xyY.c @@ -158,7 +158,24 @@ CIExyY_ParseString( &pColor->spec.CIExyY.x, &pColor->spec.CIExyY.y, &pColor->spec.CIExyY.Y) != 3) { - return(XcmsFailure); + char *s; /* Maybe failed due to locale */ + int f; + if (s = strdup(spec)) { + for (f = 0; s[f]; ++f) + if (s[f] == '.') + s[f] = ','; + else if (s[f] == ',') + s[f] = '.'; + if (sscanf(s + n + 1, "%lf/%lf/%lf", + &pColor->spec.CIExyY.x, + &pColor->spec.CIExyY.y, + &pColor->spec.CIExyY.Y) != 3) { + free(s); + return(XcmsFailure); + } + free(s); + } else + return(XcmsFailure); } pColor->format = XcmsCIExyYFormat; pColor->pixel = 0; |