ReactOS  0.4.14-dev-50-g13bb5e2
unzcrash.c File Reference
#include <stdio.h>
#include <assert.h>
#include "bzlib.h"
Include dependency graph for unzcrash.c:

Go to the source code of this file.

Macros

#define M_BLOCK   1000000
 
#define M_BLOCK_OUT   (M_BLOCK + 1000000)
 

Typedefs

typedef unsigned char uchar
 

Functions

void flip_bit (int bit)
 
int main (int argc, char **argv)
 

Variables

uchar inbuf [M_BLOCK]
 
uchar outbuf [M_BLOCK_OUT]
 
uchar zbuf [M_BLOCK+600+(M_BLOCK/100)]
 
int nIn
 
int nOut
 
int nZ
 
static charbzerrorstrings []
 

Macro Definition Documentation

◆ M_BLOCK

#define M_BLOCK   1000000

Definition at line 35 of file unzcrash.c.

◆ M_BLOCK_OUT

#define M_BLOCK_OUT   (M_BLOCK + 1000000)

Definition at line 39 of file unzcrash.c.

Typedef Documentation

◆ uchar

typedef unsigned char uchar

Definition at line 37 of file unzcrash.c.

Function Documentation

◆ flip_bit()

void flip_bit ( int  bit)

Definition at line 64 of file unzcrash.c.

65 {
66  int byteno = bit / 8;
67  int bitno = bit % 8;
68  uchar mask = 1 << bitno;
69  //fprintf ( stderr, "(byte %d bit %d mask %d)",
70  // byteno, bitno, (int)mask );
71  zbuf[byteno] ^= mask;
72 }
unsigned char uchar
Definition: Unfrag.h:59
GLenum GLint GLuint mask
Definition: glext.h:6028
uchar zbuf[M_BLOCK+600+(M_BLOCK/100)]
Definition: unzcrash.c:42

Referenced by main().

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 74 of file unzcrash.c.

75 {
76  FILE* f;
77  int r;
78  int bit;
79  int i;
80 
81  if (argc != 2) {
82  fprintf ( stderr, "usage: unzcrash filename\n" );
83  return 1;
84  }
85 
86  f = fopen ( argv[1], "r" );
87  if (!f) {
88  fprintf ( stderr, "unzcrash: can't open %s\n", argv[1] );
89  return 1;
90  }
91 
92  nIn = fread ( inbuf, 1, M_BLOCK, f );
93  fprintf ( stderr, "%d bytes read\n", nIn );
94 
95  nZ = M_BLOCK;
97  zbuf, &nZ, inbuf, nIn, 9, 0, 30 );
98 
99  assert (r == BZ_OK);
100  fprintf ( stderr, "%d after compression\n", nZ );
101 
102  for (bit = 0; bit < nZ*8; bit++) {
103  fprintf ( stderr, "bit %d ", bit );
104  flip_bit ( bit );
105  nOut = M_BLOCK_OUT;
107  outbuf, &nOut, zbuf, nZ, 0, 0 );
108  fprintf ( stderr, " %d %s ", r, bzerrorstrings[-r] );
109 
110  if (r != BZ_OK) {
111  fprintf ( stderr, "\n" );
112  } else {
113  if (nOut != nIn) {
114  fprintf(stderr, "nIn/nOut mismatch %d %d\n", nIn, nOut );
115  return 1;
116  } else {
117  for (i = 0; i < nOut; i++)
118  if (inbuf[i] != outbuf[i]) {
119  fprintf(stderr, "mismatch at %d\n", i );
120  return 1;
121  }
122  if (i == nOut) fprintf(stderr, "really ok!\n" );
123  }
124  }
125 
126  flip_bit ( bit );
127  }
128 
129 #if 0
130  assert (nOut == nIn);
131  for (i = 0; i < nOut; i++) {
132  if (inbuf[i] != outbuf[i]) {
133  fprintf ( stderr, "difference at %d !\n", i );
134  return 1;
135  }
136  }
137 #endif
138 
139  fprintf ( stderr, "all ok\n" );
140  return 0;
141 }
int BZ_API() BZ2_bzBuffToBuffDecompress(char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int small, int verbosity)
Definition: bzlib.c:1317
static int argc
Definition: ServiceArgs.c:12
#define M_BLOCK_OUT
Definition: unzcrash.c:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define assert(x)
Definition: debug.h:53
#define M_BLOCK
Definition: unzcrash.c:35
#define argv
Definition: mplay32.c:18
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define BZ_OK
Definition: bzlib.h:33
GLfloat f
Definition: glext.h:7540
void flip_bit(int bit)
Definition: unzcrash.c:64
int nOut
Definition: unzcrash.c:44
static char * bzerrorstrings[]
Definition: unzcrash.c:46
uchar inbuf[M_BLOCK]
Definition: unzcrash.c:40
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
int nZ
Definition: unzcrash.c:44
uchar zbuf[M_BLOCK+600+(M_BLOCK/100)]
Definition: unzcrash.c:42
#define f
Definition: ke_i.h:83
int BZ_API() BZ2_bzBuffToBuffCompress(char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor)
Definition: bzlib.c:1264
FILE * stderr
int nIn
Definition: unzcrash.c:44
uchar outbuf[M_BLOCK_OUT]
Definition: unzcrash.c:41

Variable Documentation

◆ bzerrorstrings

char* bzerrorstrings[]
static
Initial value:
= {
"OK"
,"SEQUENCE_ERROR"
,"PARAM_ERROR"
,"MEM_ERROR"
,"DATA_ERROR"
,"DATA_ERROR_MAGIC"
,"IO_ERROR"
,"UNEXPECTED_EOF"
,"OUTBUFF_FULL"
,"???"
,"???"
,"???"
,"???"
,"???"
,"???"
}

Definition at line 46 of file unzcrash.c.

Referenced by main().

◆ inbuf

◆ nIn

int nIn

Definition at line 44 of file unzcrash.c.

Referenced by main(), and OleStrToStrNAW().

◆ nOut

int nOut

Definition at line 44 of file unzcrash.c.

Referenced by IntGdiPolyBezier(), main(), OleStrToStrNAW(), and XCOPY_wprintf().

◆ nZ

int nZ

Definition at line 44 of file unzcrash.c.

Referenced by main().

◆ outbuf

◆ zbuf

uchar zbuf[M_BLOCK+600+(M_BLOCK/100)]

Definition at line 42 of file unzcrash.c.

Referenced by flip_bit(), and main().