Hot answers tagged

1

The input file, card.raw is empty now. Look at the following code: FILE *new_card = fopen(argv[1], "w"); As soon as you ran this code the first time, the input file card.raw was deleted and a new, empty file of the same name created. You can compare by running this command: ls -al card.raw You need to remove this section of code from the source ...


1

When you put double quotes around argv[1], it says use this text as a literal file name, so the program goes looking for a file named argv[1]. Since the file doesn't exist, the fopen() call fails and the file pointer is set to NULL. Then, the code prints that error message. The seg fault is caused by the next line, fclose(input). Since the input pointer is ...


1

This code has an infinite loop. Look at the last while condition statement: while (fread(buffer, 512, 1, forensic) <= 1); What happens when the end of the input file is reached? fread will return 0, so the loop never ends! Instead, it should check for == 1. Next, notice that every output file is 512 bytes. Remember, once the first signature is found, ...


1

There are several issues in this code. First, look at how i is being incremented. Inside the code, it is incremented by 512 in several places, but it's also being incremented by 1 in the for loop setup. That will throw the alignment to 512 byte blocks off. The test for signatures occurs in 2 places. In the first, if (buff[0] == 0xff && buff[1] == ...


Only top voted, non community-wiki answers of a minimum length are eligible