Skip to content

Instantly share code, notes, and snippets.

@proppy
Created September 10, 2010 14:17
Show Gist options
  • Save proppy/573702 to your computer and use it in GitHub Desktop.
Save proppy/573702 to your computer and use it in GitHub Desktop.
#include <assert.h>
#include <fcntl.h>
int main(int argc, int argv) {
int in, out, n;
char data[1024];
char header[1];
header[0] = 0x89;
in = open("/tmp/corrupted.png", O_RDONLY);
out = open("/tmp/corrupted2.png", O_CREAT|O_WRONLY);
read(in, data, 1024);
write(out, header, 1);
write(out, data+3, 1021);
while(n = read(in, data, 1024)) {
write(out, data, n);
}
close(in);
close(out);
return 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment