VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Boot/Windows/Decompressor.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-05-10 22:34:27 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-05-10 22:34:27 +0200
commit268ef2d8e904db5068dbdc0fdc7ce3940d6452ea (patch)
treeb1afa687c97fbf5e1ba2c92c5a10479ae5f832f5 /src/Boot/Windows/Decompressor.c
parent6d61f06a5348aebe7dbc0bf44d3e2729c20f7fd0 (diff)
parent5f47d8b6f11cdb3c4c2f43e04e5acfc6ffcb3035 (diff)
downloadVeraCrypt-268ef2d8e904db5068dbdc0fdc7ce3940d6452ea.tar.gz
VeraCrypt-268ef2d8e904db5068dbdc0fdc7ce3940d6452ea.zip
Merge pull request #61 from davidfoerster/normalize-line-terminators
Normalize line terminators
Diffstat (limited to 'src/Boot/Windows/Decompressor.c')
-rw-r--r--src/Boot/Windows/Decompressor.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/src/Boot/Windows/Decompressor.c b/src/Boot/Windows/Decompressor.c
index 475a501d..3bed8c67 100644
--- a/src/Boot/Windows/Decompressor.c
+++ b/src/Boot/Windows/Decompressor.c
@@ -83,7 +83,7 @@ local int stored(struct state *s)
s->bitbuf = 0;
s->bitcnt = 0;
- if (s->incnt + 4 > s->inlen)
+ if (s->incnt + 4 > s->inlen)
return 2; /* not enough input */
/* get length and check against its one's complement */
@@ -93,7 +93,7 @@ local int stored(struct state *s)
s->in[s->incnt++] != ((~len >> 8) & 0xff))
return -2; /* didn't match complement! */
- if (s->incnt + len > s->inlen)
+ if (s->incnt + len > s->inlen)
return 2; /* not enough input */
/* copy len bytes from in to out */
@@ -379,21 +379,21 @@ local int dynamic(struct state *s)
lengths[index++] = symbol;
else { /* repeat instruction */
len = 0; /* assume repeating zeros */
- switch(symbol)
- {
- case 16: { /* repeat last length 3..6 times */
- if (index == 0) return -5; /* no last length! */
- len = lengths[index - 1]; /* last length */
- symbol = 3 + bits(s, 2);
- break;
- }
- case 17: /* repeat zero 3..10 times */
- symbol = 3 + bits(s, 3);
- break;
- default: /* == 18, repeat zero 11..138 times */
- symbol = 11 + bits(s, 7);
- break;
- }
+ switch(symbol)
+ {
+ case 16: { /* repeat last length 3..6 times */
+ if (index == 0) return -5; /* no last length! */
+ len = lengths[index - 1]; /* last length */
+ symbol = 3 + bits(s, 2);
+ break;
+ }
+ case 17: /* repeat zero 3..10 times */
+ symbol = 3 + bits(s, 3);
+ break;
+ default: /* == 18, repeat zero 11..138 times */
+ symbol = 11 + bits(s, 7);
+ break;
+ }
if ((index + symbol > nlen + ndist))
return -6; /* too many lengths! */
while (symbol--) /* repeat last or zero symbol times */
@@ -401,8 +401,8 @@ local int dynamic(struct state *s)
}
}
- /* check for end-of-block code -- there better be one! */
- if (lengths[256] == 0)
+ /* check for end-of-block code -- there better be one! */
+ if (lengths[256] == 0)
return -9;
/* build huffman table for literal/length codes */
@@ -423,50 +423,50 @@ local int dynamic(struct state *s)
void _acrtused () { }
// Decompress deflated data
-int far main (
- unsigned char *dest, /* pointer to destination pointer */
- unsigned int destlen, /* amount of output space */
- unsigned char *source, /* pointer to source data pointer */
- unsigned int sourcelen)
-{
- struct state s; /* input/output state */
- int last, type; /* block information */
- int err; /* return value */
-
- /* initialize output state */
- s.out = dest;
- s.outlen = destlen; /* ignored if dest is NIL */
- s.outcnt = 0;
-
- /* initialize input state */
- s.in = source;
- s.inlen = sourcelen;
- s.incnt = 0;
- s.bitbuf = 0;
- s.bitcnt = 0;
-
- /* process blocks until last block or error */
- do {
- last = bits(&s, 1); /* one if last block */
- type = bits(&s, 2); /* block type 0..3 */
- switch(type)
- {
- case 0:
- err = stored(&s);
- break;
- case 1:
- err = fixed(&s);
- break;
- case 2:
- err = dynamic(&s);
- break;
- default:
- err = -1; /* type == 3, invalid */
- break;
- }
-
- if (err != 0) break; /* return with error */
- } while (!last);
-
- return err;
+int far main (
+ unsigned char *dest, /* pointer to destination pointer */
+ unsigned int destlen, /* amount of output space */
+ unsigned char *source, /* pointer to source data pointer */
+ unsigned int sourcelen)
+{
+ struct state s; /* input/output state */
+ int last, type; /* block information */
+ int err; /* return value */
+
+ /* initialize output state */
+ s.out = dest;
+ s.outlen = destlen; /* ignored if dest is NIL */
+ s.outcnt = 0;
+
+ /* initialize input state */
+ s.in = source;
+ s.inlen = sourcelen;
+ s.incnt = 0;
+ s.bitbuf = 0;
+ s.bitcnt = 0;
+
+ /* process blocks until last block or error */
+ do {
+ last = bits(&s, 1); /* one if last block */
+ type = bits(&s, 2); /* block type 0..3 */
+ switch(type)
+ {
+ case 0:
+ err = stored(&s);
+ break;
+ case 1:
+ err = fixed(&s);
+ break;
+ case 2:
+ err = dynamic(&s);
+ break;
+ default:
+ err = -1; /* type == 3, invalid */
+ break;
+ }
+
+ if (err != 0) break; /* return with error */
+ } while (!last);
+
+ return err;
}