mirror of
https://github.com/codestation/mhtools
synced 2025-03-16 06:37:01 +00:00
fix: make sure to use a 4-byte aligned input filesize so the filler
adds the correct ammount of bytes.
This commit is contained in:
parent
1643c90c45
commit
a41246dda0
2 changed files with 9 additions and 3 deletions
|
@ -67,6 +67,14 @@ public class Encrypter extends DecryptUtils implements DataKeys {
|
|||
RandomAccessFile fileout = new RandomAccessFile(out, "rw");
|
||||
int file_number = MHUtils.extractNumber(in);
|
||||
long file_len = filein.length();
|
||||
|
||||
// adjust the filesize in case isn't 4-byte aligned since the
|
||||
// encrypter works with 4-byte blocks, thx XanderXAJ for the hint :)
|
||||
if(file_len % 4 > 0) {
|
||||
file_len += 4 - (file_len % 4);
|
||||
System.out.println("The file isn't 4-byte aligned, using " + file_len + "as file size");
|
||||
}
|
||||
|
||||
long table_len = (MHUtils.getOffset(file_number + 1) << 11) - (MHUtils.getOffset(file_number) << 11);
|
||||
int filler = (int) (table_len - file_len);
|
||||
if(file_len < table_len) {
|
||||
|
|
|
@ -42,11 +42,9 @@ public class Gim extends MHUtils {
|
|||
int palette_type;
|
||||
int palette_count;
|
||||
Vector<byte[]> palettedata;
|
||||
//byte palettedata[][];
|
||||
|
||||
int max_colors;
|
||||
int palette_number;
|
||||
//int palettedata_count = 0;
|
||||
|
||||
public int load(InputStream in) throws EOFException, IOException {
|
||||
int color_size;
|
||||
|
@ -227,7 +225,7 @@ public class Gim extends MHUtils {
|
|||
break;
|
||||
}
|
||||
|
||||
switch(palette_type) {
|
||||
switch(palette_type) {
|
||||
case RGBA5650:
|
||||
case RGBA5551:
|
||||
case RGBA4444:
|
||||
|
|
Loading…
Add table
Reference in a new issue