Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 #include 2 #include 3 int main(int argc, char *argv[] { unsigned int i; unsigned int k = atoi(argv[1]); char *buf = malloc(k); /* 1
1 #include
2 #include
3
- int main(int argc, char *argv[] {
- unsigned int i;
- unsigned int k = atoi(argv[1]);
- char *buf = malloc(k); /* 1 */
- if(buf = 0) {
9 return -1;
10 }
11
12 for(i = 0; i < k; i++) {
13 buf[i] = argv[2][i]; /* 2 */
14 }
15
16 pri.ntf("%s ", buf); /* 3 */
17
18 return -1;
19 }
This program could crash at position 1 (line 7)
This program could crash at all 3 positions
This program could crash at position 2 (line 13)
This program could crash at position 2 (line 13) and 3 (line 16)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started