Alexandre Julliard wrote:
Modified files: loader : module.c
Log message: Make GetModuleFileNameA call GetModuleFileNameW. Small cleanups.
the cleanups are wrong... for example the following code:
char c[5]; DWORD len;
len = GetModuleFileNameA(0, c, 4); c[4] = '\0'; printf("len is %d/%d\n", len, strlen(c));
gives "len is 4/4" on W2K, while we get "len is 3/3" on wine when the buffer is too small, GetModuleFileName doesn't put the terminating '\0' to the string, while wine does (and my patch didn't) (and yes I do have a test sample, but that I haven't finished it yet)
A+
Eric Pouech pouech-eric@wanadoo.fr writes:
gives "len is 4/4" on W2K, while we get "len is 3/3" on wine when the buffer is too small, GetModuleFileName doesn't put the terminating '\0' to the string, while wine does (and my patch didn't) (and yes I do have a test sample, but that I haven't finished it yet)
Actually it does get null terminated, but one character too far... I guess we should add that bug too <g>
Actually it does get null terminated, but one character too far... I guess we should add that bug too <g>
I don't get this on my w2k box... the string isn't null terminated, but there isn't no buffer overflow either which windows version did you test it on ?
A+
Eric Pouech pouech-eric@wanadoo.fr writes:
I don't get this on my w2k box... the string isn't null terminated, but there isn't no buffer overflow either which windows version did you test it on ?
It's on NT4. Actually only GetModuleFileNameA has the bug, GetModuleFileNameW works as you said. Note that before we go about fixing that we need to check all the callers in Wine, there are many places where we don't expect that behavior. Also the GetLongPathNameW call won't do the right for a short buffer either.
Note that before we go about fixing that we need to check all the callers in Wine, there are many places where we don't expect that behavior.
ok, I'll take a look at that
Also the GetLongPathNameW call won't do the right for a short buffer either.
yes, MSDN is not very clear about what is done when the buffer is too small (actually writting the string or not... which it doesn't when the buffer is too small, in opposition to GetModuleFileName)
I only wish that MS could at least be consistent in their API definition, but that's may be too much to be asked <g>
A+