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
165 views

recover onlys recovers 1 image out of 16

my code for recover only successfully recovers 1 image. It seems to me that the loop only executes once. I don't know what I am doing wrong. So below is my code and I am wondering if you guys can help ...
0
votes
1answer
464 views

pset4 recover segfault: no such file/directory

My code seems to have trouble making the .jpg files in which to place the blocks of data. #include <stdio.h> #include <stdlib.h> #include <stdint.h> uint8_t buffer[512]; uint8_t ...
2
votes
1answer
213 views

why does my program recover only 3 JPEGs correctly?

When I run my recover program, it makes 16 JPG images. 3 of these JPG images (specifically, the 3rd, 8th, and 9th images) are perfect. The others, however, display question marks. When I try to open ...
0
votes
0answers
411 views

recover.c failing to fill buffer array with 512 bytes?

I am working on pset4 recover.c and I am stuck on trying to fill a buffer array with 1 block or 512 bytes from card.raw. The problem I am having is that fread successfully fills 4 bytes of data ...
0
votes
1answer
142 views

recover Only finding 8 images

Someone please help, my recover program will only find 8 images it's driving me crazy, here is my code. while(fread(block, SIZE, 1, file) > 0) { if(img) { fclose(img); } //...
0
votes
0answers
124 views

Problem in recover in pset4

I have done my recover program and I get the 16 jpg images. They are well named and I can see them so the program is working correctly but when I check the program I get an error in the set recovers ...
0
votes
1answer
179 views

Not writing to the jpegs

I'm currently struggling through recover.c, i've managed to get everything working apart from writing the actual jpegs and opens them in their individual files it just doesn't write anything to them. ...
0
votes
1answer
1k views

recover pset4 Why “error interpreting JPEG image: Improper call to JPEG library in state 201 (or 200)”

(int j is just for checking) typedef uint8_t BYTE; typedef struct { BYTE buff[512]; }__attribute__((__packed__)) BUFFER; int main(int argc, char* argv[]) { // open input file FILE* infile = ...
1
vote
1answer
547 views

why does check50 claim that 015.jpg wasn't recovered correctly? [duplicate]

This is my sandbox link: https://sandbox.cs50.net/checks/0d0024b391314b4597be136798827f98 while(feof(fp)==0) { // recover images } Edit: I'm opening only one file at time and I'm closing the ...
0
votes
1answer
189 views

why do I only find 14 JPGs?

My raw file has 16 images to recover. I can only get 14 jpg files with my code. running in valgrind returns no leaks, gdb however repeats on the following lines for a long time so I am sure the ...
0
votes
2answers
144 views

recover function causes segmentation fault

I've finished writing the recover function and made it to compile successfully. However, it gives out a segmentation fault every time I try to run it. I ran valgrind and the error was in the first if ...
0
votes
1answer
355 views

why does my recover find only 8 JPGs?

The recovered images are fine, and when comparing the recovered images with the images in card.raw using xxd, I see that they're not the first 8 images on the card. Some of the recovered images ...
0
votes
0answers
122 views

pset4 recover can't find more than one jpg

I'm doing pset4 recover program. I've written following code to read 512 bytes of data at once and detect the start of any jpg image BYTE buffer[512]; while((fread(buffer, 512 * sizeof(BYTE), 1, ...
1
vote
0answers
80 views

Why does chrome not work with server, but firefox does?

I got server (from pset6) working on Firefox, but not Chrome. Chrome will either not show anything, or just show a error message if there's an error. Everything works on Firefox, except it will not ...
0
votes
2answers
262 views

Why does my recover.c only recover 13 images?

When I run my program, only images 000.jpg through 012.jpg are recovered, and I can't figure out why. I've gone through the code over and over, checked everything, and I've added comments for ...
0
votes
1answer
92 views

fread not updating the values in my struct in recover pset4

I created a struct typedef struct { BYTE buffer[512]; } __attribute__((__packed__)) BUFFER; then I try reading card.raw and writing to a new file in a while loop fread(&photo, sizeof(...
1
vote
1answer
1k views

What is the difference in behavior between fread and feof?

For pset4's recover.c code, I noticed the following: when I set my while loop to be while (!feof(inptr)), all the images get recovered, including the last, but check50 throws an error (TODO) when ...
0
votes
1answer
44 views

Do I need to initialize my variables to a default value?

When creating a file pointer should I initialize it to NULL or should I leave it uninitialized? I currently have FILE* img;. I think the better practice is to have FILE* img = NULL; so it it doesn't ...
0
votes
1answer
337 views

check50 fails on “pset4 recover” because of an expected exit code

My recover.c code "works" in that it recovers the 16 images, but check50 is failing as follows: https://sandbox.cs50.net/checks/1b832e85fc5148e28a6ae28f24ff9f80 Any idea what that's happening? For ...
0
votes
1answer
715 views

why does check50 say “killed by server”?

My code works - all 16 images are recovered without a problem. However, it doesn't pass check50, which gives me smileys for recover.c existing and compiling, but says "killed by server" for recovering ...
2
votes
1answer
266 views

Comparing jpg-signatures with fread-buffer; Can't find something

Using the if condition I am trying to compare the buffer with the given jpg signatures, but I never find something. In GDB I just see the while looping, but never entering the if condition. What have ...
1
vote
0answers
397 views

Anyone get rick rolled in recover.c? [closed]

Did anyone get the easter egg while working recover.c? If you open the card.raw file for reading, and then: char block[512] = {0}; fread(block, sizeof(char), 512, inptr); which is incorrect, but ...
0
votes
1answer
409 views

recover finds images but check50 provides killed by server error / pset4

Recover.c appears to be working. Creates 15 jpgs and they look proper. Valgrnd suggests no memory leaks/losses. I am at a loss. > :) recover.c exists :) recover.c compiles :( recovers 000.jpg &...
-1
votes
1answer
132 views

Recover creates 16 corrupt images

Not Sure why my program is not making valid Jpegs! I am almost done!! Anyways, here is my code. I suspect it has something to do with the first write from buffer (the ones that detect jpeg file). #...
0
votes
1answer
259 views

Why won't my recover program read card.raw?

For some reason my program is not wanting to open card.raw. I have tried rearranging variables and I just don't see where I am going wrong. Any help would be appreciated! uint8_t buffer[512]; char ...
0
votes
2answers
129 views

pset4 recover: jpgs 0,4,5, and 9 not correct

I can see all the other photos. All 16 files are created. My logic is: if blank, skip if header: a) if there is an openfile, close it and open a new one, b) write block else: if nofile open,...
0
votes
1answer
303 views

PSET4 Recover only finds 13/16 images

My program runs properly through to the end of file but only recovers 13 images. Based on the fact that the jpegs are back to back and that my program reaches the end of the card.raw file, I'm ...
0
votes
2answers
191 views

Recover.c segementation fault

Can find out what i'm doing wrong.. Compiling seems to work, running the program gives a segmentation fault core dumped error. #include <stdio.h> #include <cs50.h> #include <stdlib.h&...
0
votes
1answer
2k views

Pset4 recover.c

I'm stuck. Use of undeclared identifiers img and filename... I dont get it. Something with the pointers? Could anybody give me some tips to get further. Thanks! My code: #include <stdio.h> #...
0
votes
1answer
446 views

Recover returns jpegs with wrong structure

My recover program is able to output all 16 jpg but the structure seems off as it states SOS before SOF. I'm guessing the issue might be with the fwrite function but I'm unable to figure it out. I'm ...
0
votes
1answer
778 views

Pset4 recover not passing check50, but I can see the recovered .jpg files

I have run my program and it works! I get 16 .jpg files, all of which I can see when I open them. When I run check50, however it fails on jpg 000.jpg and 001.jpg through 014.jpg, but not 015.jpg?! ...
0
votes
2answers
1k views

can someone please tell me why check50 for recover in pset 4 tells me 015 jpg is not recovered correctly if it works ok when i try it?

I don't know why but when i try working with check50 it tells everything is ok except that the015 jpg i not recovered correctly but for some reason when i actually try it and run it it says it works ...
0
votes
0answers
561 views

recover.c recovers all jpgs but fails check50 “expected xxx.jpg to exist” for all jpgs

I have checked out other posts and none seem to deal with this exact problem. My code recovers all jpgs correctly, names them as per the pset instructions however fails check50 with the error being "...
0
votes
2answers
282 views

pset4 recover code working no errors on gdb or valgrind but fail on check50

Good afternoon all! Do not understand why program is not passing check50. All images are creating, Valgrind is passing successfully. I have checked also code by gdb. Was created a special file which ...
0
votes
1answer
177 views

pset4 rm -f *.jpg deleted all folder contents

I executed the command "rm -f *.jpg" as per pset4 instructions to delete all the jpegs generated by recover.c, only it didn't just delete the jpegs, it deleted all the contents of the folder. No card....
2
votes
2answers
2k views

segmentation fault, probably because of sprintf

for my recover.c i have trouble changing the filenames. I get a segmentation fault probably because of incorrect usage of sprintf. Code looks sort of like this: { // pseudocode for testing ...
1
vote
1answer
529 views

recover.c cannot detect jpeg signatures?

Trying to get my recover.c to work. My program fread's 512 bytes into a buffer on every iteration of a loop. The buffer is declared as so: unsigned int* cfbfr = malloc(512); Then, at the start of ...
0
votes
1answer
163 views

pset5 recover seg fault woes

I've been trying to figure out what's going on for a week. Thought maybe someone would be kind enough to point me in the right direction. I get a segmentation fault. I'm not sure the code would work ...
0
votes
1answer
172 views

recover.c errors in Valgrind

I implemented pset4's recover.c and it worked fine, recovering all of the images. However, when I went to check it with valgrind to see if it didn't leak any memory it spit out a bunch of errors and ...
0
votes
2answers
529 views

Recover Finding the start of the jpg

I had been working on recover for two weeks but it is still not working. My recover program somehow is not finding the start of the jpegs, I don't know what is wrong with it can someone help please! ...
0
votes
1answer
197 views

|Recover creates only 8 files | fread | pset4|

I'm stuck with recovery program in the pset4. My program recovers 8 files. I can not find out what is wrong with it... Here is the link on Dropbox to the code I'm using. If you notice any error ...
0
votes
1answer
178 views

Recover Infinite Loop

I have been working on the "recover", however although it compiles but it tend to run into an infinite loop when searching for the start of the jpgs. Here are my coding for searching the start of the ...
8
votes
1answer
890 views

Help me write sexier code : ) counters as pointers, buffering files, feof, sprintf [pset4.recover]

I have completed the pset, and am happy with my code and how it works. But had some design questions so that I know for future programs what and why to use. I understand that it does not really ...
1
vote
1answer
1k views

Correct use of fopen, fclose, file pointers

I found this problem while working on recover.c. My program recovers all the image files, check50 says everything's cool, but when I run Valgrind, it gives me a ton of errors. After some tests, I ...
0
votes
1answer
264 views

error interpreting JPEG image file, recover.c

I can run the program and see the "thumbnail" of 16 images. However, when i clicked into the jpg files, "error interpreting JPEG image file" appeared. What does this error mean? Thanks!
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
271 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 ...