Subject: Re: PGP262i for Sun3/60-NetBSD (fwd)
To: None <mouse@Collatz.McRCIM.McGill.EDU>
From: Paul Boven <e.p.boven@student.utwente.nl>
List: port-sun3
Date: 09/01/1995 22:18:41
Hi der Mouse,
> > For some time now I've been trying to get pgp running on my Sun.
[...]
> > So I would like to know wether there are any differences in the
> > lseek() between SunOS and NetBSD (the makefile-target sun3gcc is of
> > course for SunOS).
>
> Yes, there are. Almost certainly, what is happening is that the code
> is calling lseek() without a correct prototype in scope, with an offset
> argument of type long.
Well, it does have the correct prototype included, from unistd.h
> NetBSD's lseek takes a 64-bit offset argument
> (type off_t, which is 64-bit); on a 32-bit machine like the Sun-3, if
> you manage to actually pass a 32-bit offset - which is what happens if
> you don't have a correct prototype in scope, and pass a long for that
> argument - it won't work, because the third argument will end up being
> misinterpreted as the other half of the offset, and some random garbage
> (stack trash, or whatever's in some register, or some such) will get
> used as the third argument. Not Good.
This is, indeed, what happend. The lseek() got passed a long value for it's
second argumemt, in stead of a off_t 64-bit int. What I don't understand is
that, even with -Wall, no warning was given about this. The problem is
only with lseeks, and can easily be cured by casting the second argument to
(off_t) for every occurence of lseek. Lseek is only used in the
(un)zip-code, in the files zipup.c and zunzip.c. With this little
modification, pgp seems to work 100%. Bug-report has been sent to the proper
authorities etc. Wouldn't this also affect the other members of the NetBSD-
family-tree? Anyone on Amiga/Sparc/Mac/Intel can try this?
>
> Build with -Wstrict-prototypes -Wmissing-prototypes, and pull in the
> necessary include files to prototype everything.
>
> Of course, that assumes that the pgp code itself is fully prototyped.
Alas, it isn't: using those two -W-options, I get a bit flooded with warnings
about missing prototypes etc. But the function causing these problems is
correctly prototyped, and does not generate such a warning.
> der Mouse
Credit where it is due :) Thanks for the help.
Hope this is of some use to the other Sun3/NetBSD-users.
Keep hacking! Paul.