X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinmisc.c;h=c8b92a60cbd2970749aa7e0ba466f9abf852a430;hb=b21e8ac60bac296a572a4b96fed3b09c07a98499;hp=518eb157752d7cd58845fe31a7f1531aa9802e10;hpb=cb45b9cc253d6f661b2d90003b699c1558ca2bf4;p=PuTTY.git 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);