Mail Archives: djgpp-workers/2001/01/13/16:17:40
According to Richard Dawe:
> Martin Str|mberg wrote:
> [snip]
> > > On Sat, 6 Jan 2001, Richard Dawe wrote:
> [snip]
> > > > I've just been reading about __FSEXT_llseek. 'offset_t' is
> > > > described as being a 'long long'. This is OK for the input
> > > > arguments to __FSEXT_llseek, but how do you return the offset
> > > > to the caller? The return value variable for the FSEXT handler
> > > > function is only an 'int'.
> [snip]
> > I'm not very good at the arithmetic in casting but wouldn't keeping
> > the return value as an int and casting it to long long in the llseek
> > hooker work and then convert anything < -1 to positive work?
> >
> > If this would work we would only punish the llseek() hooker.
>
> You can't really typecast the return value: 'int *' cast to 'long long *'
> will lead to memory corruption, when assigning a return value.
Of course you can't cast "int *" to "long long *" and expect anything
to work. But you can cast "int" to "long long" (not necessarily the
return value).
> The problem is returning a good (int-sized) offset to the FSEXT caller for
> __FSEXT_llseek. If you can't return a good offset, then it's broken.
There is a good (well, sufficiently non-broken at least) int-sized
return value: the range [-1, 2^32-2] which will be represented as the
range [-2^31, 2^31-1].
Right,
MartinS
- Raw text -