Fox Coverity issues

Fix CID 131712. In case parameter string does not fit in variable return a failure.
Fix CID 162913. Initialize missing data member.
Fix CID 58901.
Fix CID 149137.
Fix CID 149143.
Fix CIDs 149156, 149150, 149147, 149145, 149144, 149137. Don't use command line parameter argv directly.
This commit is contained in:
Florian Uhlig 2017-02-23 18:44:04 +01:00
parent 91b7a72ac5
commit d1cf852c98
7 changed files with 69 additions and 27 deletions

View File

@ -26,20 +26,25 @@ int main(int argc, char** argv)
testPub.CatchSignals();
std::string transport;
if (argc != 2)
if ( (argc != 2) || (argv[1] == NULL) )
{
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
testPub.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
testPub.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}

View File

@ -28,20 +28,25 @@ int main(int argc, char** argv)
testSub.CatchSignals();
std::string transport;
if (argc != 2)
if ( (argc != 2) || (argv[1] == NULL) )
{
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
testSub.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
testSub.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}

View File

@ -26,20 +26,25 @@ int main(int argc, char** argv)
testPull.CatchSignals();
std::string transport;
if (argc != 2)
if ( (argc != 2) || (argv[1] == NULL) )
{
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
testPull.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
testPull.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}

View File

@ -32,15 +32,25 @@ int main(int argc, char** argv)
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if (argv[1] == NULL) {
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
testPush.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
testPush.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}

View File

@ -27,20 +27,26 @@ int main(int argc, char** argv)
testRep.CatchSignals();
std::string transport;
if (argc != 2)
if ( (argc != 2) || (argv[1] == NULL) )
{
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
testRep.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
testRep.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}

View File

@ -28,20 +28,25 @@ int main(int argc, char** argv)
testReq.CatchSignals();
std::string transport;
if (argc != 2)
if ( (argc != 2) || (argv[1] == NULL) )
{
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
testReq.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
testReq.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}

View File

@ -66,20 +66,26 @@ int main(int argc, char** argv)
timeoutTester.CatchSignals();
std::string transport;
if (argc != 2)
if ( (argc != 2) || (argv[1] == NULL) )
{
LOG(ERROR) << "Transport for the test not specified!";
return 1;
}
transport = argv[1];
if (transport == "zeromq" || transport == "nanomsg")
if ( strncmp(argv[1],"zeromq",6) == 0 )
{
transport = "zeromq";
timeoutTester.SetTransport(transport);
}
else if ( strncmp(argv[1],"nanomsg",7) == 0 )
{
transport = "nanomsg";
timeoutTester.SetTransport(transport);
}
else
{
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << transport;
LOG(ERROR) << "Incorrect transport requested! Expected 'zeromq' or 'nanomsg', found: " << argv[1];
return 1;
}