NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/59711: "#define HAVE_UNISTD_H 1" breaks 32-bit libz
The following reply was made to PR lib/59711; it has been noted by GNATS.
From: Tom Lane <tgl%sss.pgh.pa.us@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: lib/59711: "#define HAVE_UNISTD_H 1" breaks 32-bit libz
Date: Sat, 18 Oct 2025 23:23:57 -0400
Here's the promised test case. You can exercise it along the lines of
$ gcc libztest.c -lz
$ cp libztest.c datafile
$ gzip datafile
$ ./a.out datafile.gz | diff - libztest.c
If things are working, "diff" will not complain, and you'll just
see a report about "sizeof pos" on stderr. However, on macppc
I see
sizeof pos = 8
could not read from input file: (null)
on stderr, and then diff reports that most of the file is missing.
Removing "#define HAVE_UNISTD_H 1" results in a working program
that reports sizeof pos = 4.
regards, tom lane
------------ cut here: libztest.c -------------
#define HAVE_UNISTD_H 1
#include <zlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int
main(int argc, char **argv)
{
gzFile gzfp;
fprintf(stderr, "sizeof pos = %zu\n", sizeof(gzfp->pos));
gzfp = gzopen(argv[1], "r");
if (gzfp == NULL)
{
fprintf(stderr, "gzopen(%s) failed\n", argv[1]);
return 1;
}
for (;;)
{
char buf[8];
int gzret;
gzret = gzread(gzfp, buf, sizeof(buf));
if (gzret <= 0)
{
int errnum;
const char *errmsg;
if (gzret == 0 && gzeof(gzfp))
break;
errmsg = gzerror(gzfp, &errnum);
fprintf(stderr, "could not read from input file: %s\n",
errnum == Z_ERRNO ? strerror(errno) : errmsg);
return 1;
}
fwrite(buf, 1, gzret, stdout);
gzret = gzgetc(gzfp);
if (gzret == -1)
break;
putchar(gzret);
}
gzclose(gzfp);
return 0;
}
------------ cut here: libztest.c -------------
Home |
Main Index |
Thread Index |
Old Index