Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static code analysis _046 (Cast Alters Value - priority1) #70

Open
PawelModrzejewski opened this issue Dec 22, 2020 · 0 comments
Open

Comments

@PawelModrzejewski
Copy link
Contributor

Short summary (details in attached file):

GptpIniParser::iniCallBack()
.../common/gptp_cfg.cpp

    if( parseMatch(name, "priority1") )
    {
        errno = 0;
        char *pEnd;
        unsigned char p1 = (unsigned char) strtoul(value, &pEnd, 10);
        if( *pEnd == '\0' && errno == 0) {
            valOK = true;
            parser->_config.priority1 = p1;
        }
    }

strtoul(value, &pEnd, 10) could be 256 or higher.
Values 256 or higher cannot be stored as unsigned char.  Casting them to unsigned char can cause data loss or sign change.

gptp_046.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant