From e7ee47769429a25d175507beb3e6b12fd4dcd8fd Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sun, 27 Feb 2000 17:25:13 +0000 Subject: [PATCH] GetComputerNameA(): added parameter check like Win95 does. --- win32/init.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/win32/init.c b/win32/init.c index 1b14e782e85..eb0350698a0 100644 --- a/win32/init.c +++ b/win32/init.c @@ -10,13 +10,22 @@ #include #include "winerror.h" #include "wine/winestring.h" +#include "wine/exception.h" #include "heap.h" #include "task.h" #include "debugtools.h" #include "process.h" -DEFAULT_DEBUG_CHANNEL(win32) +DEFAULT_DEBUG_CHANNEL(win32); +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + /*********************************************************************** * GetStartupInfoA (KERNEL32.273) */ @@ -76,10 +85,22 @@ VOID WINAPI GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo) */ BOOL WINAPI GetComputerNameA(LPSTR name,LPDWORD size) { - if (-1==gethostname(name,*size)) - return FALSE; + /* At least Win95OSR2 survives if size is not a pointer (NT crashes though) */ + BOOL ret; + __TRY + { + ret = (-1!=gethostname(name,*size)); + if (ret) *size = lstrlenA(name); - return TRUE; + } + __EXCEPT(page_fault) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + __ENDTRY + + return ret; } /***********************************************************************