[or-cvs] Check return value from GetVersionEx (even though the MSDN ...

Nick Mathewson nickm at seul.org
Fri Mar 24 05:26:37 UTC 2006


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv23190/src/common

Modified Files:
	compat.c 
Log Message:
Check return value from GetVersionEx (even though the MSDN example doesnt) and zero out the LPOSVERSIONINFOEX struct before getting the version.  This may fix the "johnboy" [major=-858993460,minor=-858993460] problem.

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -p -d -r1.83 -r1.84
--- compat.c	13 Feb 2006 08:01:59 -0000	1.83
+++ compat.c	24 Mar 2006 05:26:33 -0000	1.84
@@ -742,8 +742,15 @@ get_uname(void)
           { VER_SUITE_TERMINAL,           " {terminal services}" },
           { 0, NULL },
         };
+        memset(&info, 0, sizeof(info));
         info.dwOSVersionInfoSize = sizeof(info);
-        GetVersionEx((LPOSVERSIONINFO)&info);
+        if (! GetVersionEx((LPOSVERSIONINFO)&info)) {
+          int err = GetLastError();
+          strlcpy(uname_result, "Bizarre version of Windows where GetVersionEx"
+                  " doesn't work.", sizeof(uname_result));
+          uname_result_is_set = 1;
+          return uname_result;
+        }
         if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) {
           if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
             plat = "Windows NT 4.0";



More information about the tor-commits mailing list