Questions tagged [recover]

recover.c, one of the assignments for Problem Set 4, will challenge you to search through the raw bytes of a camera's digital memory to recover a bunch of "deleted" JPEG images.

Filter by
Sorted by
Tagged with
0
votes
1answer
298 views

pset4 recover: Code works 3/4 times. Sometimes gives segmentation fault. Doesn't pass check50

I'm having trouble figuring out what is going on. 3/4 times I run ./recover, it produces all 16 pictures correctly. Other times, I get a segmentation fault. When I run valgrind it gives me two "Use of ...
0
votes
1answer
459 views

fread not putting what I expect in buffer

for Pset4, recover, I'm trying to read 4 bytes from card.raw into a buffer. I''m testing the first 4 bytes of card.raw with what my buffer contains using gdb, and I'm not getting the same thing. I ...
0
votes
1answer
497 views

pset6 2015, server.c, ERR_CONTENT_LENGTH_MISMATCH on cat.jpg

I respond to the client with the following function call: dprintf(cfd, "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: %i\r\nContent-Type: %s\r\n\r\n%s", length, type, body); This works, ...
0
votes
0answers
105 views

pset5 picture problems: jpg recovery

I have two main problems with recover: Does not recover 049.jpg - Is this because my program is getting a freak EOF? check50 hates me - Although my program recovers 000.jpg through 048.jpg fine, ...
1
vote
2answers
275 views

i'm able to recover the 49th image but does check50 says unable to recover the 49th image

I spent hours but still then i'm not able to understand that why does check50 does not recognize my 49th recovered image eventhough i have recovered that image and i can see that the image is of ...
0
votes
1answer
519 views

Pset5 Recover Only Generating 49 images

To start, I've come a long way because I have gotten lots of help looking over all other questions & answers here, thank you!! Currently, I can run recover.c successfully, and it will recover ...
0
votes
1answer
84 views

Cant validate whether file being read is JPEG or not in recover

I cannot validate whether the file is JPEG or not with a help of the pattern. Thanks in advance. Here is my simple code: typedef uint8_t BYTE; int main(int argc, char* argv[]) { char* ...
0
votes
1answer
121 views

i++ doesn't work as expected

This is for pset5, reading card.raw - but I think this is general issue. int i = 0; while(true) { i++; } Example above works just fine - it counts 0,1,2,3 etc. But example below doesn't count. ...
0
votes
1answer
423 views

How do I add leading zeros to the filename in `recover`?

I wrote a perfectly functional recover.c program yesterday. But I can't get the file naming right. How can I add leading zeroes to the file name so the name is 000 instead of just 0?
0
votes
1answer
942 views

Recover Buffer as uint8_t instead of int

I have been struggling through Recover when I noticed that the buffer on the walk through was a BYTE buffer; instead of just an int buffer;. After changing this my program finally worked! My ...
0
votes
1answer
139 views

Infinite loop and unable to check for next JPG

My program is stuck in a loop and I can't figure out why. The problem is in the do while loop but logically it should work. The program checks performs fwrite and then freads a new 512 bytes to the ...
1
vote
2answers
773 views

What is the meaning of this segmentation fault?

For recover.c my program compiles but when I run gdb I get a segmentation fault and I'm not quite sure what it means. When I run gdb I reach line 59 before I get this error message. I would like to ...
-1
votes
1answer
381 views

Recover Never Stops

I've been slowly moving through recover, and have figured out how to recover all 50 images. Unfortunately, the program never stops running (I hit ctrl + c to stop it) and the 50th image, while ...
0
votes
0answers
149 views

All pictures recovered, Valgrind OK, but Check50 won´t accept the pictures

I was thrilled to see that all the pictures were recovered to the jpg-folder with the correct filenames, but shocked to see that my program was still running! I had to Ctrl + C to end it. I managed ...
0
votes
1answer
460 views

pset5-recover help

UPDATE-1 #include <stdio.h> #include <stdint.h> #include <ctype.h> typedef uint8_t BYTE; typedef struct { BYTE buff[512]; } __attribute__((__packed__)) BUFFER; int main() { ...
0
votes
1answer
176 views

pset5 recover video

In the video offering tips for the "Recover" assignment, a graphic is shown, which depict the blocks of memory containing the jpeg files. The last block of memory is shown as "EOF" and appears to not ...
1
vote
2answers
662 views

check50 says “bmp.h” not found even though “bmp.h” is in jpg directory

Hello all I have a question about compiling what I've written for recover.c The compiler shows me this message when I try to compile recover: " expected an exit code of 0, not standard error of ...
0
votes
1answer
267 views

pset5 recover creates 50 corrupted images

I seem to have in issue writing data inside my loop, so that 50 JPGs are created with only 1 block of content each. I am checking for the beginning of a new JPG, and open a new output file inside that ...
2
votes
1answer
323 views

Recover creates an unreadable image file and then segfaults

I am pulling my hair out over recover.c in pset5. My code manages to generate 1 appropriately named (but unreadable) jpg and then fails with segmentation fault. I have tried to figure it out by ...
0
votes
1answer
83 views

Do CS50x students need to take part in the contest in pset5?

After the Computer Science Investigation (CSI), there is a contest about taking pictures with CS50 staff. See the link: http://youtu.be/Y4vV61lbL3g?t=9m23s
0
votes
2answers
586 views

recover all the images as expected but fails check50 last 3 tests

I recovers all the 50 images and check my program correctness through check50. but it fails last three test can you check my code and tell me where i'm wrong here's the check50 error :) recover.c ...
0
votes
2answers
240 views

Seg fault in recover.c pset5

I don't know why it's showing seg fault. Could anyone please tell me what I've done wrong? #include<stdio.h> #include<stdint.h> #include<stdlib.h> typedef uint8_t BYTE; ...
0
votes
2answers
22k views

How to create an array/subarray by extracting a part of another array?

Does anyone know how one can create a subarray by extracting a part of an existing array. Is there something like subarray[] =existingArray[0-3]? I need this to compare the first 4 bytes of my block ...
-1
votes
1answer
170 views

How to read the next sector in recover?

Below is the code that i have written when i execute the code i get jpg images but they are corrupted.Any help regarding it? //reading the sector and checking the condition do { fread(from ...
0
votes
1answer
485 views

Error: double free or corruption when running recover

After a very long time, I finally managed to find out why my version of recover.c only managed to recover 1 image (recover.c only recovers 1 image) Anyway, now I face a new problem. What I've ...
0
votes
1answer
573 views

recover returns corrupted images

I'm currently writing recover.c for pset5 last exercise. The program I designed runs ok, outputs the expected amount of JPGs at what I would expect to be reasonable sizes. However the JPGs are broken ...
0
votes
2answers
810 views

recover.c only recovers 1 image

I'm having a problem with my code for recover.c because it recovers only 1 JPEG and that JPEG isn't a JPEG. It starts with 0x68 and 0x74. After going through the code with GDB, it seems as that on ...
0
votes
1answer
377 views

Recover pset5 scope?

I'm almost there, but one more question about recover.. In my code, I open a file inside an if condition, but how do I acces that file later? It's getting out of scope and I'm getting use of ...
0
votes
1answer
326 views

pset 5 Recover check if file open

How do I check if I already opened a jpeg file to write to? I could declare an int outside of the loop that I set to 1 if I open a file, but I think there must be another way... Some kind of function ...
1
vote
1answer
634 views

Recover creates the pictures, able to view them, but listed as jpg? in ls and check50 fails

I checked the boards and couldn't find if anyone else had the same issue. For some reason, Recover runs 'seemingly' correctly when I ask it to and I see the pictures in the folder from "000.jpg" to "...
1
vote
1answer
2k views

recover end of file detection

I'm having a lot of trouble with recover. I have written some code, just to get the basic structure. I was trying to iterate over the raw file until the end, printing when stumbled upon a jpeg. ...
4
votes
1answer
3k views

What data structure do you use to store the buffer in recover?

What data structure do I use to store the 512B blocks in a buffer? Thinking about an array or ints? Or am I completely off?
2
votes
1answer
1k views

Can't recover 049.jpg successfully

The 049.jpg file is created but not recovered! I have used the fread function to detect the EOF as told in the walk through by Zamyla. Here is a link to the check50 sandbox output. # Checks 0 ...
0
votes
1answer
135 views

JPEG output files are blank

All of my program seems to be functioning but my JPEG images are completely blank. I'm not sure, but I think the error is somewhere in this code: if ((buffer[0] == 0xFF) && (buffer[1] == 0xD8)...
0
votes
1answer
651 views

pset5 recover error with jpeg file

I keep getting "error interpreting jpeg image file (Not a jpeg file: starts with 0x00 0xd8)", even though gdb tells me buffer[0] is 0xff. A similar question has been posted on reddit, but I couldn't ...
1
vote
1answer
118 views

Can anyone tell why is this giving me a SEGFAULT?

typedef uint8_t BYTE; int main(void) { FILE* memcard = fopen("card.raw", "r"); if (memcard == NULL) { printf("something went wrong and file could not be opened"); return ...
0
votes
1answer
776 views

Seg Fault in Recover.c

I cannot seem to get to get rid of this seg fault. In my loop I basically have this (semi-pseudo code): fread(in); if(nf == 0xffd8ffe0 || nf == 0xffd8ffe1) { f++; fclose(out); ...
1
vote
1answer
870 views

Pset 5 - Recover

Having problems with recover (pset5) now. This is what I'm doing: Opening File Until the end of file Reading 512 bytes to buffer Checking first 4 bytes of buffer to see if a jpg has just ...
1
vote
1answer
377 views

Recover.c Segmentation Fault

Pseudocode: declare counter declare filename[8] main Open input Declare buffer do read(512 bytes into buffer from input) while (not start of jpeg) do write filename open ...
0
votes
1answer
1k views

segmentation fault - pset5 recover.c

I have spent a long time looking through my code for a segmentation fault, but have not been able to find it. #include <stdio.h> #include <stdlib.h> #include <stdint.h> #define ...
1
vote
1answer
3k views

Cannot figure out what is wrong with recover - “Improper call to JPEG library in state 201”

Does anyone know why I might be receiving this error in my recover program? I've used xxd to confirm that the first four bytes are correct and signal that each is a jpeg. However, I am still receiving ...
1
vote
2answers
177 views

Trouble incrementing the number in jpeg filenames

I've gotten recover to work... sort of. The problem is difficult to describe without posting my code, but here's an attempt: My program can find all the jpg signatures (in GDB, my jpeg-finding line ...
3
votes
3answers
998 views

Proper use of fread function

I have declared a buffer as follows : unsigned int buffer[512]; Now, later on in my code I used fread in the following manner fread(buffer, 512, 1, infile) and everything worked as expected. Note ...
0
votes
1answer
72 views

How on Earth can this variable change without any commands? Please help!

As you can see, the value of buffer[0] changes when the line sprintf(tittle, %03d.jpg", images);, which has nothing to do with the buffer. All of the values in buffer are changed. I went through my ...
2
votes
2answers
412 views

Is it possible to see the actual bytes of card.raw?

Is it possible to see the actual bytes of card.raw from pset5?
1
vote
1answer
120 views

Why is this condition true if the characters in the buffer do not match?

As you can see, the if statement on the line 35 is false. Why is the body of the if statement being executed?
1
vote
2answers
185 views

How to build a “.raw ” image of a storage media?

In pset 5 David gave us his SD card's card.raw file to recover deleted JPEG images from. What are these .raw disk images and how can we build them to create practice problems similar to pset 5 for ...
-1
votes
3answers
330 views

Why Doesn't check50 Recognize My Recovered Images?

when I use check50 to check my recover program for pset 5, it says that the pictures are not recovered, but when I look in the file directory, all of the 50 pictures are perfectly recovered. How could ...
0
votes
1answer
595 views

recover.c recovers all images successfully, but check50 says it fails to recover the last. Any ideas why this is happening?

I have a while (!feof(infile)) loop, so that exits only when the eof is reached. And it closes all files upon exit. Here's the code: // scan input file while (!feof(infile)) { // read four bytes ...

1
14 15 16 17
18