OLD | NEW |
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include <openssl/objects.h> | 4 #include <openssl/objects.h> |
5 #include <openssl/comp.h> | 5 #include <openssl/comp.h> |
6 | 6 |
7 static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, | 7 static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, |
8 unsigned int olen, unsigned char *in, unsigned int ilen); | 8 unsigned int olen, unsigned char *in, unsigned int ilen); |
9 static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | 9 static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, |
10 unsigned int olen, unsigned char *in, unsigned int ilen); | 10 unsigned int olen, unsigned char *in, unsigned int ilen); |
(...skipping 28 matching lines...) Expand all Loading... |
39 *(out++)=0; | 39 *(out++)=0; |
40 memcpy(out,in,ilen); | 40 memcpy(out,in,ilen); |
41 return(ilen+1); | 41 return(ilen+1); |
42 } | 42 } |
43 | 43 |
44 static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | 44 static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, |
45 unsigned int olen, unsigned char *in, unsigned int ilen) | 45 unsigned int olen, unsigned char *in, unsigned int ilen) |
46 { | 46 { |
47 int i; | 47 int i; |
48 | 48 |
49 » if (olen < (ilen-1)) | 49 » if (ilen == 0 || olen < (ilen-1)) |
50 { | 50 { |
51 /* ZZZZZZZZZZZZZZZZZZZZZZ */ | 51 /* ZZZZZZZZZZZZZZZZZZZZZZ */ |
52 return(-1); | 52 return(-1); |
53 } | 53 } |
54 | 54 |
55 i= *(in++); | 55 i= *(in++); |
56 if (i == 0) | 56 if (i == 0) |
57 { | 57 { |
58 memcpy(out,in,ilen-1); | 58 memcpy(out,in,ilen-1); |
59 } | 59 } |
60 return(ilen-1); | 60 return(ilen-1); |
61 } | 61 } |
62 | |
OLD | NEW |