Bug 58977 - use of locale atof to parse non localized values - segfault in cd-create-profile
Summary: use of locale atof to parse non localized values - segfault in cd-create-profile
Status: RESOLVED FIXED
Alias: None
Product: colord
Classification: Unclassified
Component: client (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-03 11:12 UTC by Alban Browaeys
Modified: 2013-01-03 13:15 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Fixes use of atof in non "C" locale environments. (3.89 KB, patch)
2013-01-03 11:12 UTC, Alban Browaeys
Details | Splinter Review

Description Alban Browaeys 2013-01-03 11:12:58 UTC
Created attachment 72436 [details] [review]
Fixes use of atof in non "C" locale environments.

atof is local dependant. Ie passing 1.0 to atof with in a french
environment leads to segfault in lcms for create-standard-space:
primaries are all equal to 0 due to the dot not meaning decimal
separator in this locale. Thus we get a null lcms profile from
cmsCreateRGBProfile. Then as we pass this null profile to lcms,
lcms segfault.

This was with AdobeRGB1998.icc :
../../client/cd-create-profile --output AdobeRGB1998.icc \
        create-standard-space                   \
        --description "Adobe RGB (1998)"        \
        --metadata
"License="CC0",DATA_source=standard,STANDARD_space=adobe-rgb" \
        2.2 D65                                 \
        0.6400 0.3300 0.297361                  \
        0.2100 0.7100 0.627355                  \
        0.1500 0.0600 0.075285
Comment 1 Richard Hughes 2013-01-03 13:15:51 UTC
Good catch, thanks! I've decided to fix this another way, to use g_ascii_strtod which is locale independent and also allows us to check for parsing errors at the same time. I've committed this:

commit 8d88b402fed63e6de1792801ca185b4f68b5edd0
Author: Richard Hughes <richard@hughsie.com>
Date:   Thu Jan 3 12:19:06 2013 +0000

    Fix floating point number parsing in non C locale environments
    
    atof() is local dependant. Passing 1.0 to atof with in a French environment
    leads to segfault in lcms for create-standard-space as the primaries are all
    equal to 0 due to the dot not meaning decimal separator in this locale.
    
    Thus we get a null lcms profile from cmsCreateRGBProfile. Then as we pass this
    null profile to lcms, which results in a segfault.
    
    Many thanks to Alban Browaeys <prahal@yahoo.com> for debugging the problem.
    
    Resolves: https://bugs.freedesktop.org/show_bug.cgi?id=58977

:100644 100644 71025be... d556cb0... M  client/cd-create-profile.c
:100644 100644 d70bd77... 386b4c5... M  client/cd-fix-profile.c


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.