Question: 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

  1. int main(int argc, char *argv[] {
  2. unsigned int i;
  3. unsigned int k = atoi(argv[1]);
  4. char *buf = malloc(k); /* 1 */
  5. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!