Reference no: EM133851942
Question: For each of the code fragments below, identify the type of software flaw(s) found and suggest a way to fix the issue(s). It is recommended that you identify the problem without using a computer. After identifying the problem, you may use a computer to verify your answer.
Code Fragment #1
void sampleFunc(char inStr[])
{
char buf[10];
buf[9]='\0';
strcpy(buf,inStr);
cout<<"\n"<<buf<<"\n";
return;
}
Code Fragment #2
Using Code Fragment #1, carry out research on banned function calls and rewrite the code using an equivalent, but secure, function from the Safe C Runtime Library.
Code Fragment #3
Enable Code Fragment #1 to be able to throw an exception to handle the excessive string length issue. Also, add a main function with an exception handling mechanism that will handle the exception that is thrown. Get expert online assignment help in the USA now!
Submit a 2- to 3-page paper in APA format that contains the original code fragment, a description of the coding flaw in each, and your proposed solution using defensive programming technique(s) to fix it.
Your document should be 2-3 pages long (not including the list of references and cover page), but it is the quality of the work that is important, not the number of pages. Cite and reference all sources using APA format and style guidelines and submit in a single document.