diff --git a/cpp/ql/src/Critical/OverflowDestination.cpp b/cpp/ql/src/Critical/OverflowDestination.cpp index 1a758430bf4..02c5281d0b6 100644 --- a/cpp/ql/src/Critical/OverflowDestination.cpp +++ b/cpp/ql/src/Critical/OverflowDestination.cpp @@ -1,13 +1,13 @@ int main(int argc, char* argv[]) { - char param[SIZE]; + char param[20]; + char *arg1; - char arg1[10]; - char arg2[20]; + arg1 = argv[1]; //wrong: only uses the size of the source (argv[1]) when using strncpy - strncpy(param, argv[1], strlen(arg1)); + strncpy(param, arg1, strlen(arg1)); //correct: uses the size of the destination array as well - strncpy(param, argv[1], min(strlen(arg1, sizeof(param) -1))); + strncpy(param, arg1, min(strlen(arg1), sizeof(param) -1)); }