Fix lossage due to pathname truncation in calls to MODULE_LoadLibraryExA
david at l8s.co.uk
Thu Sep 12 11:29:18 CDT 2002
> > Argl, why does this code use the buffer size contants instead of
> > sizeof(variable) !?
> > I suggest we always specify buffer length constants only *once*,
> > namely at creation of the buffer.
> > Not doing so can be potentially very harmful if we decide to change
> > the buffer length and then manage to forget one or more length constants...
> However I don't think saying something like sizeof(bufferW) is a clear winner
> here, as we're not interested in the size in terms of the number of bytes (or
> number of items of data of type char to be pedantic) of bufferW, but rather
> the number of elements in bufferW. To get the number of elements in bufferW
> we'd have to use sizeof(bufferW) / sizeof(WCHAR), which is a bit long winded,
> but I suppose could be wrapped by a macro.
The 'usual' definition is sizeof bufferW / sizeof *bufferW
sometimes encapsulated in a NELEM (or nelem) macro:
#define nelem(x) (sizeof (x) / sizeof *(x))
Then the constant only appears once.
Indeed you have to ask whether MAX_PATH is an enforced system restraint
or just wishful thinking.
Certainly the NetBSD kernel doesn't enforce it (although some shells
enforce it (or other arbitrary limits) on the length of $PWD.
David Laight: david at l8s.co.uk
More information about the wine-devel