Loading src/common/compat.c +32 −17 Original line number Diff line number Diff line Loading @@ -695,6 +695,7 @@ get_uname(void) #ifdef MS_WINDOWS OSVERSIONINFOEX info; int i; unsigned int leftover_mask; const char *plat = NULL; static struct { int major; int minor; const char *version; Loading @@ -710,6 +711,21 @@ get_uname(void) { 3, 51, "Windows NT 3.51" }, { -1, -1, NULL } }; static struct { unsigned int mask; const char *str; } win_mask_table[] = { { VER_SUITE_BACKOFFICE, " {backoffice}" }, { VER_SUITE_BLADE, " {\"blade\" (2003, web edition)}" }, { VER_SUITE_DATACENTER, " {datacenter}" }, { VER_SUITE_ENTERPRISE, " {enterprise}" }, { VER_SUITE_EMBEDDEDNT, " {embedded}" }, { VER_SUITE_PERSONAL, " {personal}" }, { VER_SUITE_SINGLEUSERTS, " {terminal services, single user}" }, { VER_SUITE_SMALLBUSINESS, " {small business}" }, { VER_SUITE_SMALLBUSINESS_RESTRICTED, " {small business, restricted}" }, { VER_SUITE_TERMINAL, " {terminal services}" }, { 0, NULL }, }; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx((LPOSVERSIONINFO)&info); if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) { Loading @@ -733,12 +749,14 @@ get_uname(void) if (info.dwMajorVersion > 6 || (info.dwMajorVersion==6 && info.dwMinorVersion>0)) tor_snprintf(uname_result, sizeof(uname_result), "Very recent version of Windows [major=%d,minor=%d]", (int)info.dwMajorVersion,(int)info.dwMinorVersion); "Very recent version of Windows [major=%d,minor=%d] %s", (int)info.dwMajorVersion,(int)info.dwMinorVersion, info.szCSDVersion); else tor_snprintf(uname_result, sizeof(uname_result), "Unrecognized version of Windows [major=%d,minor=%d]", (int)info.dwMajorVersion,(int)info.dwMinorVersion); "Unrecognized version of Windows [major=%d,minor=%d] %s", (int)info.dwMajorVersion,(int)info.dwMinorVersion, infor.szCSDVersion); } if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) { strlcat(uname_result, " [domain controller]", sizeof(uname_result)); Loading @@ -747,20 +765,17 @@ get_uname(void) } else if (info.wProductType == VER_NT_WORKSTATION) { strlcat(uname_result, " [workstation]", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_DATACENTER) { strlcat(uname_result, " {datacenter}", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_ENTERPRISE) { strlcat(uname_result, " {enterprise}", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_PERSONAL) { strlcat(uname_result, " {personal}", sizeof(uname_result)); leftover_mask = info.wSuiteMask; for (i = 0; win_mask_table[i].mask; ++i) { if (info.wSuiteMask & win_mask_table[i]) { strlcat(uname_result, win_mask_table[i].str, sizeof(uname_result)); leftover_mask &= ~win_mask_table[i].mask; } if (info.wSuiteMask & VER_SUITE_EMBEDDEDNT) { strlcat(uname_result, " {personal}", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_PERSONAL) { strlcat(uname_result, " {personal}", sizeof(uname_result)); if (leftover_mask) { size_t len = strlen(uname_result); tor_snprintf(uname_result+len, sizeof(uname_result)-len, " {0x%x}", info.wSuiteMask); } #else strlcpy(uname_result, "Unknown platform", sizeof(uname_result)); Loading src/common/log.h +5 −2 Original line number Diff line number Diff line Loading @@ -52,8 +52,7 @@ /* Logging domains */ /** Catch-all for miscellaneous events and internal errors and fatal * errors. */ /** Catch-all for miscellaneous events and fatal errors */ #define LD_GENERAL 0 /** The cryptography subsytem */ #define LD_CRYPTO 1 Loading @@ -77,6 +76,10 @@ #define LD_CIRC 10 /** Hidden services */ #define LD_REND 11 /** Internal errors in this Tor process. */ #define LD_BUG 12 /** Learning and using information about Tor servers. */ #define LD_DIR 13 typedef void (*log_callback)(int severity, int domain, const char *msg); Loading src/common/tortls.c +1 −1 Original line number Diff line number Diff line Loading @@ -689,7 +689,7 @@ log_cert_lifetime(X509 *cert, const char *problem) problem); if (!(bio = BIO_new(BIO_s_mem()))) { log_fn(LOG_WARN, LD_GENERAL, "Couldn't allocate BIO!"); goto end; warn(LD_GENERAL, "Couldn't allocate BIO!"); goto end; } if (!(ASN1_TIME_print(bio, X509_get_notBefore(cert)))) { tls_log_errors(LOG_WARN, "printing certificate lifetime"); Loading src/common/util.c +6 −3 Original line number Diff line number Diff line Loading @@ -909,7 +909,7 @@ check_private_dir(const char *dirname, cpd_check_t check) if (st.st_mode & 0077) { log(LOG_WARN, LD_FS, "Fixing permissions on directory %s", dirname); if (chmod(dirname, 0700)) { log(LOG_WARN, LD_GENERAL, "Could not chmod directory %s: %s", dirname, log(LOG_WARN, LD_FS, "Could not chmod directory %s: %s", dirname, strerror(errno)); return -1; } else { Loading @@ -930,8 +930,8 @@ write_str_to_file(const char *fname, const char *str, int bin) { #ifdef MS_WINDOWS if (!bin && strchr(str, '\r')) { warn(LD_GENERAL, "How odd. Writing a string that does contain CR already."); warn(LD_BUG, "Bug: we're writing a text string that already contains a CR."); } #endif return write_bytes_to_file(fname, str, strlen(str), bin); Loading Loading @@ -1243,6 +1243,9 @@ tor_listdir(const char *dirname) } result = smartlist_create(); while (1) { if (!strcmp(findData.cFileName, ".") || !strcmp(findData.cFileName, "..")) continue; smartlist_add(result, tor_strdup(findData.cFileName)); if (!FindNextFile(handle, &findData)) { if (GetLastError() != ERROR_NO_MORE_FILES) { Loading Loading
src/common/compat.c +32 −17 Original line number Diff line number Diff line Loading @@ -695,6 +695,7 @@ get_uname(void) #ifdef MS_WINDOWS OSVERSIONINFOEX info; int i; unsigned int leftover_mask; const char *plat = NULL; static struct { int major; int minor; const char *version; Loading @@ -710,6 +711,21 @@ get_uname(void) { 3, 51, "Windows NT 3.51" }, { -1, -1, NULL } }; static struct { unsigned int mask; const char *str; } win_mask_table[] = { { VER_SUITE_BACKOFFICE, " {backoffice}" }, { VER_SUITE_BLADE, " {\"blade\" (2003, web edition)}" }, { VER_SUITE_DATACENTER, " {datacenter}" }, { VER_SUITE_ENTERPRISE, " {enterprise}" }, { VER_SUITE_EMBEDDEDNT, " {embedded}" }, { VER_SUITE_PERSONAL, " {personal}" }, { VER_SUITE_SINGLEUSERTS, " {terminal services, single user}" }, { VER_SUITE_SMALLBUSINESS, " {small business}" }, { VER_SUITE_SMALLBUSINESS_RESTRICTED, " {small business, restricted}" }, { VER_SUITE_TERMINAL, " {terminal services}" }, { 0, NULL }, }; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx((LPOSVERSIONINFO)&info); if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) { Loading @@ -733,12 +749,14 @@ get_uname(void) if (info.dwMajorVersion > 6 || (info.dwMajorVersion==6 && info.dwMinorVersion>0)) tor_snprintf(uname_result, sizeof(uname_result), "Very recent version of Windows [major=%d,minor=%d]", (int)info.dwMajorVersion,(int)info.dwMinorVersion); "Very recent version of Windows [major=%d,minor=%d] %s", (int)info.dwMajorVersion,(int)info.dwMinorVersion, info.szCSDVersion); else tor_snprintf(uname_result, sizeof(uname_result), "Unrecognized version of Windows [major=%d,minor=%d]", (int)info.dwMajorVersion,(int)info.dwMinorVersion); "Unrecognized version of Windows [major=%d,minor=%d] %s", (int)info.dwMajorVersion,(int)info.dwMinorVersion, infor.szCSDVersion); } if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) { strlcat(uname_result, " [domain controller]", sizeof(uname_result)); Loading @@ -747,20 +765,17 @@ get_uname(void) } else if (info.wProductType == VER_NT_WORKSTATION) { strlcat(uname_result, " [workstation]", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_DATACENTER) { strlcat(uname_result, " {datacenter}", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_ENTERPRISE) { strlcat(uname_result, " {enterprise}", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_PERSONAL) { strlcat(uname_result, " {personal}", sizeof(uname_result)); leftover_mask = info.wSuiteMask; for (i = 0; win_mask_table[i].mask; ++i) { if (info.wSuiteMask & win_mask_table[i]) { strlcat(uname_result, win_mask_table[i].str, sizeof(uname_result)); leftover_mask &= ~win_mask_table[i].mask; } if (info.wSuiteMask & VER_SUITE_EMBEDDEDNT) { strlcat(uname_result, " {personal}", sizeof(uname_result)); } if (info.wSuiteMask & VER_SUITE_PERSONAL) { strlcat(uname_result, " {personal}", sizeof(uname_result)); if (leftover_mask) { size_t len = strlen(uname_result); tor_snprintf(uname_result+len, sizeof(uname_result)-len, " {0x%x}", info.wSuiteMask); } #else strlcpy(uname_result, "Unknown platform", sizeof(uname_result)); Loading
src/common/log.h +5 −2 Original line number Diff line number Diff line Loading @@ -52,8 +52,7 @@ /* Logging domains */ /** Catch-all for miscellaneous events and internal errors and fatal * errors. */ /** Catch-all for miscellaneous events and fatal errors */ #define LD_GENERAL 0 /** The cryptography subsytem */ #define LD_CRYPTO 1 Loading @@ -77,6 +76,10 @@ #define LD_CIRC 10 /** Hidden services */ #define LD_REND 11 /** Internal errors in this Tor process. */ #define LD_BUG 12 /** Learning and using information about Tor servers. */ #define LD_DIR 13 typedef void (*log_callback)(int severity, int domain, const char *msg); Loading
src/common/tortls.c +1 −1 Original line number Diff line number Diff line Loading @@ -689,7 +689,7 @@ log_cert_lifetime(X509 *cert, const char *problem) problem); if (!(bio = BIO_new(BIO_s_mem()))) { log_fn(LOG_WARN, LD_GENERAL, "Couldn't allocate BIO!"); goto end; warn(LD_GENERAL, "Couldn't allocate BIO!"); goto end; } if (!(ASN1_TIME_print(bio, X509_get_notBefore(cert)))) { tls_log_errors(LOG_WARN, "printing certificate lifetime"); Loading
src/common/util.c +6 −3 Original line number Diff line number Diff line Loading @@ -909,7 +909,7 @@ check_private_dir(const char *dirname, cpd_check_t check) if (st.st_mode & 0077) { log(LOG_WARN, LD_FS, "Fixing permissions on directory %s", dirname); if (chmod(dirname, 0700)) { log(LOG_WARN, LD_GENERAL, "Could not chmod directory %s: %s", dirname, log(LOG_WARN, LD_FS, "Could not chmod directory %s: %s", dirname, strerror(errno)); return -1; } else { Loading @@ -930,8 +930,8 @@ write_str_to_file(const char *fname, const char *str, int bin) { #ifdef MS_WINDOWS if (!bin && strchr(str, '\r')) { warn(LD_GENERAL, "How odd. Writing a string that does contain CR already."); warn(LD_BUG, "Bug: we're writing a text string that already contains a CR."); } #endif return write_bytes_to_file(fname, str, strlen(str), bin); Loading Loading @@ -1243,6 +1243,9 @@ tor_listdir(const char *dirname) } result = smartlist_create(); while (1) { if (!strcmp(findData.cFileName, ".") || !strcmp(findData.cFileName, "..")) continue; smartlist_add(result, tor_strdup(findData.cFileName)); if (!FindNextFile(handle, &findData)) { if (GetLastError() != ERROR_NO_MORE_FILES) { Loading