X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/31fb1866040c36038f24c1e2e79e36bf35993279..055817455466c8eb60392f30bb7c689763962e17:/windows/winmisc.c diff --git a/windows/winmisc.c b/windows/winmisc.c index 518eb157..c8b92a60 100644 --- a/windows/winmisc.c +++ b/windows/winmisc.c @@ -50,8 +50,14 @@ char *get_username(void) char *user; namelen = 0; - if (GetUserName(NULL, &namelen) == FALSE) - return NULL; + if (GetUserName(NULL, &namelen) == FALSE) { + /* + * Apparently this doesn't work at least on Windows XP SP2. + * Thus assume a maximum of 256. It will fail again if it + * doesn't fit. + */ + namelen = 256; + } user = snewn(namelen, char); GetUserName(user, &namelen);