NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/44594: kernel zlib reports false errors on decompression
The following reply was made to PR kern/44594; it has been noted by GNATS.
From: Matthias Drochner <M.Drochner%fz-juelich.de@localhost>
To: <gnats-bugs%NetBSD.org@localhost>
Cc:
Subject: Re: kern/44594: kernel zlib reports false errors on decompression
Date: Thu, 17 Feb 2011 19:19:30 +0100
--==_Exmh_792027469890
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Here is the test program.
---------------------------------------------------------------------------=
---------------------
---------------------------------------------------------------------------=
---------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDirig Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
---------------------------------------------------------------------------=
---------------------
---------------------------------------------------------------------------=
---------------------
--==_Exmh_792027469890
Content-Type: text/plain; name="compbug.c"; charset="us-ascii"
Content-Description: compbug.c
Content-Disposition: attachment; filename="compbug.c"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include "zlib.h"
/* This unpacks into 1508, exactly 52*29. */
unsigned char text[29] = {
0xe3,0x60,0xa8,0x9d,0x5e,0xf9,0x9d,0x81,0xc1,0x37,
0x56,0xc5,0x8f,0x81,0xb7,0x6f,0x07,0xc3,0x28,0x18,
0x05,0xa3,0x60,0x14,0x8c,0x82,0x61,0x03,0x00
};
#define FACTOR 4 /* fails with 1, 2, 4, 13, 26, 52 */
static void *
myalloc(void *o, unsigned int n, unsigned int s)
{
return calloc(n, s);
}
static void
myfree(void *o, void *p)
{
free(p);
}
int
main()
{
int res, nbuf;
unsigned char buf1[10000];
z_stream z;
memset(&z, 0, sizeof(z));
z.next_in = text;
z.avail_in = sizeof(text);
z.zalloc = myalloc;
z.zfree = myfree;
z.opaque = 0;
z.next_out = buf1;
z.avail_out = FACTOR * sizeof(text);
res = inflateInit2(&z, -15);
if (res != Z_OK)
errx(1, "inflateInit: %d", res);
nbuf = 1;
for(;;) {
res = inflate(&z, Z_SYNC_FLUSH);
if (res != Z_OK)
break;
if (z.avail_out == 0) {
z.next_out = buf1;
z.avail_out = FACTOR * sizeof(text);
nbuf++;
}
}
if (res != Z_STREAM_END) {
printf("ai=%d ao=%d bufs=%d out=%ld\n",
z.avail_in, z.avail_out, nbuf, z.total_out);
errx(1, "inflate: %d", res);
}
printf("got %ld bytes in %d bufs\n", z.total_out, nbuf);
return 0;
}
--==_Exmh_792027469890--
Home |
Main Index |
Thread Index |
Old Index