Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
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.
1
vote
Accepted
PSET 4 Recover.c Segmentation Fault
Use fread, not fwrite in the while loop condition, and use memcard instead of image
fwrite only if image != NULL
fclose(image); only if image != NULL
You start with 001.jpg, it should have been 000.j …
1
vote
Accepted
Segmentation fault and only one unreadable image - RECOVER
For "%03i.jpg", you need at least 8 char (7 for the file name like 000.jpg, and one for the null terminator).
DO NOT open a file in your else path, it just makes no sense, especially with a filename …
1
vote
Accepted
Image not recovering completely in recover.c(in pset4)
Ask de Morgan (Disclaimer: I've studied physics, boolean logic was part of the maths curriculum)
The opposite of
data[0]==0xff&&data[1]==0xd8&&data[2]==0xff&&(data[3]==0xe0||data[3]==0xe1)
is
dat …
0
votes
pset4 recover handles lack of forensic image
The error message you describe is due to your code not testing argc. You are meant to complain if no file name is passed, and use argv[1] as the file name if it is provided. card.raw is just the sampl …
1
vote
pset4 recover it shows segmentation fault
feof in this case makes no sense. It checks the EOF flag, which is set after an unsuccessful read. In that case, fread would have returned 0, so you would not be there. Likewise, do not fclose(infile) …
2
votes
Accepted
problem with checking 4 bytes of jpeg
The problem is with the array/pointer type.
You declared it as int[]/int*, with an int on our system being 32 bit, or 4 bytes long. So all the first four bytes are within that first element.
The wal …
0
votes
Why can I recover only two images?
/recover card.raw …
1
vote
Accepted
PSet4 recover.c SegFault: cannot figure it out!
Here you fwrite even when outptr is still NULL.
//write the rest of the buffer until the if condition triggers the loop above
else
{
fwrite(buffer, sizeof(buffer), …
0
votes
pset4 recover code review
You code is much more complicated than necessary.
int count = 0;
FILE* img[count];
You create an array of length 0, so there's no space on the stack associated with that variable.
You don' …
2
votes
Accepted
recover.c encounters seg fault after 1024 bytes
I see two writes that are way off:
fread(&bytes, 32 , 1, pf);
reads 32 bytes into a uint8_t[4], a 4-byte buffer
fread(&reader, 512, 1, raw)
reads 512 bytes into an int, which is a 2 to 8 byte va …
0
votes
Struggling with recover.c
Please initialize
FILE* tempjpgg = NULL;
(In my experience, some compilers initialize to zero automatically, others don't)
Also, firstint should point to the beginning of your 512 bytes, so instea …
0
votes
Can't Find JPEG's in pset4 - Recover
Files start at index 0, not 1.
Pass buffer, not &buffer, as buffer is a pointer to a byte (and can be used as an array), while &buffer is a pointer to a pointer to a byte, so you'd overwrite your poi …
1
vote
Accepted
PSET4: recover - Segmentation fault: 11
You could locate the place of the segfault using debug50, here I'm just guessing where I'd expect a segfault.
fread(&buffer, 1, 512, pmem)
should be
fread(buffer, 1, 512, pmem)
buffer is a point …
1
vote
Accepted
Recover seems to be recovering incomplete or illegible images
In while ((fread (buffer, 1, 512, inptr)) != 0) you read a 512 byte block of data. Just after that, in if (((fread (buffer, 1,512, inptr)) < 512) && (FILEOPENED == true)), you read another 512 byte bl …
1
vote
Recover segmentation fault :(
First: sample is the pointer you want to pass to fread and fwrite, not &sample. Otherwise you risk segfaults there.
Second: You cannot fclose(NULL), but that's what happens on encountering first JPEG …