Andreas Rosenberg wrote:
It's quite common for these functions to check for the needed buffersize when buffer=NULL and size=0 is passed.
I did a quick check on W2K3 and this is what is returned:
sizePath = 0; SetLastError( 0xDEADBEEF ); r = GetUserProfileDirectoryA( htoken , NULL, &sizePath );
userenv.c:298: (A) r : 0, sizePath : 0, GLE : 87/00000057
sizePath = 0; SetLastError( 0xDEADBEEF ); r = GetUserProfileDirectoryW( htoken , NULL, &sizePath );
userenv.c:304: (W) r : 0, sizePath : 40, GLE : 122/0000007a
So one suggestion is to also add some A-checks to the tests. Another one is not to rely on buffer[MAX_PATH] but use the returned required buffersize for further processing (HeapAlloc).