summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2014-01-19 19:22:59 +0100
committerDirk Engling <erdgeist@erdgeist.org>2014-01-19 19:22:59 +0100
commit12d4de8c84af22702132e3d2187441f68e206312 (patch)
treefb012d50e75086170016435694c51f8d97a75031 /src
parent4e33872678d38319e3bb6bd98584dcb78aae5940 (diff)
Fix the case where encrypted part is longer than header. Also do not assume anymore that compressed file size is < 65k
Diffstat (limited to 'src')
-rw-r--r--src/extractblocks_new.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/extractblocks_new.c b/src/extractblocks_new.c
index c3fb899..580d3ad 100644
--- a/src/extractblocks_new.c
+++ b/src/extractblocks_new.c
@@ -24,7 +24,7 @@
24 24
25*/ 25*/
26 26
27static uint8_t mantra_in[] = { 0x68, 0x00, 0x2d, 0x6c }; 27static uint8_t mantra_in[] = { 0x68, 0x35, 0x2d, 0x6c };
28 28
29int main( int args, char **argv ) 29int main( int args, char **argv )
30{ 30{
@@ -54,7 +54,7 @@ int main( int args, char **argv )
54 mappedfile = map->addr; 54 mappedfile = map->addr;
55 55
56 mantra[0] = mantra_in[0] ^ mappedfile[4]; 56 mantra[0] = mantra_in[0] ^ mappedfile[4];
57 mantra[1] = mantra_in[1] ^ mappedfile[9]; 57 mantra[1] = mantra_in[1] ^ mappedfile[5];
58 mantra[2] = mantra_in[2] ^ mappedfile[2]; 58 mantra[2] = mantra_in[2] ^ mappedfile[2];
59 mantra[3] = mantra_in[3] ^ mappedfile[3]; 59 mantra[3] = mantra_in[3] ^ mappedfile[3];
60 60
@@ -106,8 +106,13 @@ int main( int args, char **argv )
106 106
107 /* Open file and dump our de-"crypted" header and then rest of file */ 107 /* Open file and dump our de-"crypted" header and then rest of file */
108 i = open( filename, O_CREAT | O_TRUNC | O_WRONLY, 0644 ); 108 i = open( filename, O_CREAT | O_TRUNC | O_WRONLY, 0644 );
109 write( i, df, header_len ); 109 if( enc_len > header_len ) {
110 write( i, mf + header_len, offset - oldoffset - header_len ); 110 write( i, df, enc_len );
111 write( i, mf + enc_len, offset - oldoffset - enc_len );
112 } else {
113 write( i, df, header_len );
114 write( i, mf + header_len, offset - oldoffset - header_len );
115 }
111 close( i ); 116 close( i );
112 } 117 }
113 oldoffset = offset; 118 oldoffset = offset;