| 1 |
/* Copyright (C) 2008 Vincent Penquerc'h. |
| 2 |
This file is part of the Kate codec library. |
| 3 |
Written by Vincent Penquerc'h. |
| 4 |
|
| 5 |
Use, distribution and reproduction of this library is governed |
| 6 |
by a BSD style source license included with this source in the |
| 7 |
file 'COPYING'. Please read these terms before distributing. */ |
| 8 |
|
| 9 |
|
| 10 |
#ifdef HAVE_CONFIG_H |
| 11 |
#include "config.h" |
| 12 |
#endif |
| 13 |
#include <ogg/ogg.h> |
| 14 |
#include "kate/kate.h" |
| 15 |
#include "kfuzz.h" |
| 16 |
|
| 17 |
#ifdef DEBUG |
| 18 |
|
| 19 |
unsigned long gen_fuzz(unsigned long *seed) |
| 20 |
{ |
| 21 |
return *seed=*seed*65521+0x9e370001UL; |
| 22 |
} |
| 23 |
|
| 24 |
unsigned long gen_fuzz_n(unsigned long *seed,unsigned long n) |
| 25 |
{ |
| 26 |
return gen_fuzz(seed)%n; |
| 27 |
} |
| 28 |
|
| 29 |
static void fuzz_packet(unsigned long *seed,unsigned long nbytes,unsigned char *data) |
| 30 |
{ |
| 31 |
unsigned long n=gen_fuzz_n(seed,4),i; |
| 32 |
if (n!=0) return; |
| 33 |
n=gen_fuzz_n(seed,8); |
| 34 |
for (i=0;i<n;++i) { |
| 35 |
unsigned long offset=gen_fuzz_n(seed,nbytes); |
| 36 |
data[offset]^=1; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
void fuzz_kate_packet(unsigned long *seed,kate_packet *kp) |
| 41 |
{ |
| 42 |
fuzz_packet(seed,kp->nbytes,kp->data); |
| 43 |
} |
| 44 |
|
| 45 |
void fuzz_ogg_packet(unsigned long *seed,ogg_packet *op) |
| 46 |
{ |
| 47 |
fuzz_packet(seed,op->bytes,op->packet); |
| 48 |
} |
| 49 |
|
| 50 |
#endif |
| 51 |
|