disable debug on release

This commit is contained in:
EqUiNoX
2026-02-16 08:59:39 -07:00
parent 19d1d774a1
commit 505e5f7611
10 changed files with 1342 additions and 513 deletions
+6
View File
@@ -0,0 +1,6 @@
*.suo
*.user
*.ncb
[Dd]ebug/
[Rr]elease/
+17 -17
View File
@@ -324,7 +324,7 @@ int ca_loader::load_pem_file(const char *path,
FILE *f = fopen(path, "rb");
if (f == NULL)
{
debug_utility::debug_print("ca_loader: cannot open %s\n", path);
debug_log("ca_loader: cannot open %s\n", path);
return -1;
}
@@ -334,7 +334,7 @@ int ca_loader::load_pem_file(const char *path,
if (file_size <= 0 || file_size > 2 * 1024 * 1024)
{
debug_utility::debug_print("ca_loader: file too large or empty (%ld bytes)\n", file_size);
debug_log("ca_loader: file too large or empty (%ld bytes)\n", file_size);
fclose(f);
return -1;
}
@@ -342,7 +342,7 @@ int ca_loader::load_pem_file(const char *path,
unsigned char *file_data = (unsigned char *)malloc((size_t)file_size);
if (file_data == NULL)
{
debug_utility::debug_print("ca_loader: malloc failed for file data\n");
debug_log("ca_loader: malloc failed for file data\n");
fclose(f);
return -1;
}
@@ -352,7 +352,7 @@ int ca_loader::load_pem_file(const char *path,
if (bytes_read != (size_t)file_size)
{
debug_utility::debug_print("ca_loader: short read (%u of %ld)\n",
debug_log("ca_loader: short read (%u of %ld)\n",
(unsigned)bytes_read, file_size);
free(file_data);
return -1;
@@ -457,7 +457,7 @@ int ca_loader::load_pem_file(const char *path,
byte_buffer_free(&dn_buf);
free(file_data);
debug_utility::debug_print("ca_loader: loaded %d trust anchors from %s (%d failed)\n",
debug_log("ca_loader: loaded %d trust anchors from %s (%d failed)\n",
certs_parsed, path, certs_failed);
if (anchor_count == 0)
@@ -556,7 +556,7 @@ int ca_loader::download_https(const char *host, const char *path,
uint32_t host_ip = ca_resolve_host(host);
if (host_ip == 0)
{
debug_utility::debug_print("ca_loader: DNS failed for %s\n", host);
debug_log("ca_loader: DNS failed for %s\n", host);
return -1;
}
@@ -564,7 +564,7 @@ int ca_loader::download_https(const char *host, const char *path,
SOCKET sock = ca_connect(host_ip, port);
if (sock == INVALID_SOCKET)
{
debug_utility::debug_print("ca_loader: connect failed to %s:%u\n",
debug_log("ca_loader: connect failed to %s:%u\n",
host, (unsigned)port);
return -1;
}
@@ -724,7 +724,7 @@ int ca_loader::download_https(const char *host, const char *path,
if ((status_code == 301 || status_code == 302 || status_code == 307)
&& has_redirect && max_redirects > 0)
{
debug_utility::debug_print("ca_loader: redirect %d -> %s%s\n",
debug_log("ca_loader: redirect %d -> %s%s\n",
status_code, redirect_host, redirect_path);
byte_buffer_free(&hdr);
@@ -738,7 +738,7 @@ int ca_loader::download_https(const char *host, const char *path,
if (status_code != 200)
{
debug_utility::debug_print("ca_loader: HTTP %d from %s%s\n",
debug_log("ca_loader: HTTP %d from %s%s\n",
status_code, host, path);
byte_buffer_free(&hdr);
free(readbuf);
@@ -755,7 +755,7 @@ int ca_loader::download_https(const char *host, const char *path,
FILE *fp = fopen(temp_path, "wb");
if (fp == NULL)
{
debug_utility::debug_print("ca_loader: cannot create %s (err=%lu)\n",
debug_log("ca_loader: cannot create %s (err=%lu)\n",
temp_path, GetLastError());
byte_buffer_free(&hdr);
free(readbuf);
@@ -803,7 +803,7 @@ int ca_loader::download_https(const char *host, const char *path,
/* Check for disk write errors */
if (write_error)
{
debug_utility::debug_print("ca_loader: write error saving to %s\n",
debug_log("ca_loader: write error saving to %s\n",
temp_path);
remove(temp_path);
return -1;
@@ -812,7 +812,7 @@ int ca_loader::download_https(const char *host, const char *path,
/* Sanity check: CA bundles are typically 200-300 KB */
if (total_written < 1024)
{
debug_utility::debug_print("ca_loader: download too small (%I64d bytes)\n",
debug_log("ca_loader: download too small (%I64d bytes)\n",
total_written);
remove(temp_path);
return -1;
@@ -822,13 +822,13 @@ int ca_loader::download_https(const char *host, const char *path,
remove(save_path);
if (rename(temp_path, save_path) != 0)
{
debug_utility::debug_print("ca_loader: rename %s -> %s failed\n",
debug_log("ca_loader: rename %s -> %s failed\n",
temp_path, save_path);
remove(temp_path);
return -1;
}
debug_utility::debug_print("ca_loader: downloaded %I64d bytes to %s\n",
debug_log("ca_loader: downloaded %I64d bytes to %s\n",
total_written, save_path);
result = 0;
return result;
@@ -842,18 +842,18 @@ int ca_loader::update_trust_store(const char *save_path,
if (f != NULL)
{
fclose(f);
debug_utility::debug_print("ca_loader: %s already exists, skipping download\n",
debug_log("ca_loader: %s already exists, skipping download\n",
save_path);
return 0;
}
if (anchors == NULL || anchor_count == 0)
{
debug_utility::debug_print("ca_loader: no trust anchors for download\n");
debug_log("ca_loader: no trust anchors for download\n");
return -1;
}
debug_utility::debug_print("ca_loader: downloading CA bundle from %s...\n",
debug_log("ca_loader: downloading CA bundle from %s...\n",
CA_BUNDLE_HOST);
return download_https(CA_BUNDLE_HOST, CA_BUNDLE_PATH, CA_BUNDLE_PORT,
+2 -1
View File
@@ -2,6 +2,7 @@
#include "ca_loader.h"
#include <bearssl_x509.h>
#include <xtl.h>
#include "debug_utility.h"
#include "trust_anchors.h"
@@ -23,7 +24,7 @@ void certificates::initialize_trust_anchors()
trust_anchors = (br_x509_trust_anchor*)malloc(NUM_TRUST_ANCHORS * sizeof br_x509_trust_anchor);
if (trust_anchors == NULL)
{
OutputDebugStringA("certificates: FATAL - malloc failed for trust anchors!\n");
debug_log("certificates: FATAL - malloc failed for trust anchors!\n");
return;
}
trust_anchor_count = NUM_TRUST_ANCHORS;
+5 -1
View File
@@ -4,6 +4,8 @@
#include <stdio.h>
#include <stdarg.h>
#ifdef _DEBUG
int debug_utility::debug_print(const char* format, ...)
{
/* Use a fixed buffer since VS2003 doesn't support va_copy */
@@ -25,4 +27,6 @@ int debug_utility::debug_print(const char* format, ...)
OutputDebugStringA(message);
return length;
}
}
#endif
+6
View File
@@ -1,5 +1,11 @@
#pragma once
#ifdef _DEBUG
#define debug_log debug_utility::debug_print
#else
#define debug_log(...) ((void)0)
#endif
class debug_utility
{
public:
File diff suppressed because it is too large Load Diff
@@ -1286,15 +1286,8 @@ br_ssl_hs_client_run(void *t0ctx)
break;
case 32: {
/* debug-session-ticket */
extern void __stdcall OutputDebugStringA(const char *);
extern int sprintf(char *, const char *, ...);
char buf[80];
size_t len = T0_POP();
sprintf(buf, "BearSSL: NewSessionTicket received (%u bytes)\r\n",
(unsigned)len);
OutputDebugStringA(buf);
size_t len = T0_POP();
debug_log("BearSSL: NewSessionTicket received (%u bytes)\r\n", len);
}
break;
case 33: {
+6 -6
View File
@@ -22,42 +22,42 @@ void ssl_debug::log_error(const char* format, ...)
{
if (current_level < SSL_DEBUG_ERROR) return;
debug_utility::debug_print("[SSL ERROR] ");
debug_log("[SSL ERROR] ");
va_list args;
va_start(args, format);
char buffer[256];
_vsnprintf(buffer, sizeof(buffer) - 1, format, args);
buffer[sizeof(buffer) - 1] = '\0';
va_end(args);
debug_utility::debug_print("%s", buffer);
debug_log("%s", buffer);
}
void ssl_debug::log_info(const char* format, ...)
{
if (current_level < SSL_DEBUG_INFO) return;
debug_utility::debug_print("[SSL] ");
debug_log("[SSL] ");
va_list args;
va_start(args, format);
char buffer[256];
_vsnprintf(buffer, sizeof(buffer) - 1, format, args);
buffer[sizeof(buffer) - 1] = '\0';
va_end(args);
debug_utility::debug_print("%s", buffer);
debug_log("%s", buffer);
}
void ssl_debug::log_verbose(const char* format, ...)
{
if (current_level < SSL_DEBUG_VERBOSE) return;
debug_utility::debug_print("[SSL DEBUG] ");
debug_log("[SSL DEBUG] ");
va_list args;
va_start(args, format);
char buffer[256];
_vsnprintf(buffer, sizeof(buffer) - 1, format, args);
buffer[sizeof(buffer) - 1] = '\0';
va_end(args);
debug_utility::debug_print("%s", buffer);
debug_log("%s", buffer);
}
const char* ssl_debug::version_to_string(unsigned version)
File diff suppressed because it is too large Load Diff
+265 -89
View File
@@ -34,7 +34,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/libcurl.lib"/>
OutputFile="$(OutDir)/libcurld.lib"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
@@ -118,87 +118,237 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<Filter
Name="lib">
<File RelativePath=".\lib\base64.c"/>
<File RelativePath=".\lib\conncache.c"/>
<File RelativePath=".\lib\connect.c"/>
<File RelativePath=".\lib\content_encoding.c"/>
<File RelativePath=".\lib\cookie.c"/>
<File RelativePath=".\lib\curl_addrinfo.c"/>
<File RelativePath=".\lib\curl_ctype.c"/>
<File RelativePath=".\lib\curl_endian.c"/>
<File RelativePath=".\lib\curl_fnmatch.c"/>
<File RelativePath=".\lib\curl_get_line.c"/>
<File RelativePath=".\lib\curl_gethostname.c"/>
<File RelativePath=".\lib\curl_memrchr.c"/>
<File RelativePath=".\lib\curl_multibyte.c"/>
<File RelativePath=".\lib\curl_range.c"/>
<File RelativePath=".\lib\curl_threads.c"/>
<File RelativePath=".\lib\dotdot.c"/>
<File RelativePath=".\lib\easy.c"/>
<File RelativePath=".\lib\escape.c"/>
<File RelativePath=".\lib\file.c"/>
<File RelativePath=".\lib\fileinfo.c"/>
<File RelativePath=".\lib\formdata.c"/>
<File RelativePath=".\lib\ftp.c"/>
<File RelativePath=".\lib\ftplistparser.c"/>
<File RelativePath=".\lib\getenv.c"/>
<File RelativePath=".\lib\getinfo.c"/>
<File RelativePath=".\lib\hash.c"/>
<File RelativePath=".\lib\hmac.c"/>
<File RelativePath=".\lib\hostasyn.c"/>
<File RelativePath=".\lib\hostcheck.c"/>
<File RelativePath=".\lib\hostip.c"/>
<File RelativePath=".\lib\hostip4.c"/>
<File RelativePath=".\lib\hostsyn.c"/>
<File RelativePath=".\lib\http.c"/>
<File RelativePath=".\lib\http_chunks.c"/>
<File RelativePath=".\lib\http_proxy.c"/>
<File RelativePath=".\lib\if2ip.c"/>
<File RelativePath=".\lib\inet_ntop.c"/>
<File RelativePath=".\lib\inet_pton.c"/>
<File RelativePath=".\lib\llist.c"/>
<File RelativePath=".\lib\mime.c"/>
<File RelativePath=".\lib\mprintf.c"/>
<File RelativePath=".\lib\multi.c"/>
<File RelativePath=".\lib\netrc.c"/>
<File RelativePath=".\lib\non-ascii.c"/>
<File RelativePath=".\lib\nonblock.c"/>
<File RelativePath=".\lib\parsedate.c"/>
<File RelativePath=".\lib\progress.c"/>
<File RelativePath=".\lib\rand.c"/>
<File RelativePath=".\lib\select.c"/>
<File RelativePath=".\lib\sendf.c"/>
<File RelativePath=".\lib\setopt.c"/>
<File RelativePath=".\lib\sha256.c"/>
<File RelativePath=".\lib\share.c"/>
<File RelativePath=".\lib\slist.c"/>
<File RelativePath=".\lib\socks.c"/>
<File RelativePath=".\lib\speedcheck.c"/>
<File RelativePath=".\lib\splay.c"/>
<File RelativePath=".\lib\strcase.c"/>
<File RelativePath=".\lib\strdup.c"/>
<File RelativePath=".\lib\strerror.c"/>
<File RelativePath=".\lib\strtok.c"/>
<File RelativePath=".\lib\strtoofft.c"/>
<File RelativePath=".\lib\system_win32.c"/>
<File RelativePath=".\lib\timeval.c"/>
<File RelativePath=".\lib\transfer.c"/>
<File RelativePath=".\lib\url.c"/>
<File RelativePath=".\lib\urlapi.c"/>
<File RelativePath=".\lib\version.c"/>
<File RelativePath=".\lib\warnless.c"/>
<File RelativePath=".\lib\wildcard.c"/>
<File RelativePath=".\lib\x509asn1.c"/>
<File
RelativePath=".\lib\base64.c">
</File>
<File
RelativePath=".\lib\conncache.c">
</File>
<File
RelativePath=".\lib\connect.c">
</File>
<File
RelativePath=".\lib\content_encoding.c">
</File>
<File
RelativePath=".\lib\cookie.c">
</File>
<File
RelativePath=".\lib\curl_addrinfo.c">
</File>
<File
RelativePath=".\lib\curl_ctype.c">
</File>
<File
RelativePath=".\lib\curl_endian.c">
</File>
<File
RelativePath=".\lib\curl_fnmatch.c">
</File>
<File
RelativePath=".\lib\curl_get_line.c">
</File>
<File
RelativePath=".\lib\curl_gethostname.c">
</File>
<File
RelativePath=".\lib\curl_memrchr.c">
</File>
<File
RelativePath=".\lib\curl_multibyte.c">
</File>
<File
RelativePath=".\lib\curl_range.c">
</File>
<File
RelativePath=".\lib\curl_threads.c">
</File>
<File
RelativePath=".\lib\dotdot.c">
</File>
<File
RelativePath=".\lib\easy.c">
</File>
<File
RelativePath=".\lib\escape.c">
</File>
<File
RelativePath=".\lib\file.c">
</File>
<File
RelativePath=".\lib\fileinfo.c">
</File>
<File
RelativePath=".\lib\formdata.c">
</File>
<File
RelativePath=".\lib\ftp.c">
</File>
<File
RelativePath=".\lib\ftplistparser.c">
</File>
<File
RelativePath=".\lib\getenv.c">
</File>
<File
RelativePath=".\lib\getinfo.c">
</File>
<File
RelativePath=".\lib\hash.c">
</File>
<File
RelativePath=".\lib\hmac.c">
</File>
<File
RelativePath=".\lib\hostasyn.c">
</File>
<File
RelativePath=".\lib\hostcheck.c">
</File>
<File
RelativePath=".\lib\hostip.c">
</File>
<File
RelativePath=".\lib\hostip4.c">
</File>
<File
RelativePath=".\lib\hostsyn.c">
</File>
<File
RelativePath=".\lib\http.c">
</File>
<File
RelativePath=".\lib\http_chunks.c">
</File>
<File
RelativePath=".\lib\http_proxy.c">
</File>
<File
RelativePath=".\lib\if2ip.c">
</File>
<File
RelativePath=".\lib\inet_ntop.c">
</File>
<File
RelativePath=".\lib\inet_pton.c">
</File>
<File
RelativePath=".\lib\llist.c">
</File>
<File
RelativePath=".\lib\mime.c">
</File>
<File
RelativePath=".\lib\mprintf.c">
</File>
<File
RelativePath=".\lib\multi.c">
</File>
<File
RelativePath=".\lib\netrc.c">
</File>
<File
RelativePath=".\lib\non-ascii.c">
</File>
<File
RelativePath=".\lib\nonblock.c">
</File>
<File
RelativePath=".\lib\parsedate.c">
</File>
<File
RelativePath=".\lib\progress.c">
</File>
<File
RelativePath=".\lib\rand.c">
</File>
<File
RelativePath=".\lib\select.c">
</File>
<File
RelativePath=".\lib\sendf.c">
</File>
<File
RelativePath=".\lib\setopt.c">
</File>
<File
RelativePath=".\lib\sha256.c">
</File>
<File
RelativePath=".\lib\share.c">
</File>
<File
RelativePath=".\lib\slist.c">
</File>
<File
RelativePath=".\lib\socks.c">
</File>
<File
RelativePath=".\lib\speedcheck.c">
</File>
<File
RelativePath=".\lib\splay.c">
</File>
<File
RelativePath=".\lib\strcase.c">
</File>
<File
RelativePath=".\lib\strdup.c">
</File>
<File
RelativePath=".\lib\strerror.c">
</File>
<File
RelativePath=".\lib\strtok.c">
</File>
<File
RelativePath=".\lib\strtoofft.c">
</File>
<File
RelativePath=".\lib\system_win32.c">
</File>
<File
RelativePath=".\lib\timeval.c">
</File>
<File
RelativePath=".\lib\transfer.c">
</File>
<File
RelativePath=".\lib\url.c">
</File>
<File
RelativePath=".\lib\urlapi.c">
</File>
<File
RelativePath=".\lib\version.c">
</File>
<File
RelativePath=".\lib\warnless.c">
</File>
<File
RelativePath=".\lib\wildcard.c">
</File>
<File
RelativePath=".\lib\x509asn1.c">
</File>
</Filter>
<Filter
Name="vtls">
<File RelativePath=".\lib\vtls\bearssl.c"/>
<File RelativePath=".\lib\vtls\vtls.c"/>
<File
RelativePath=".\lib\vtls\bearssl.c">
</File>
<File
RelativePath=".\lib\vtls\vtls.c">
</File>
</Filter>
<Filter
Name="vauth">
<File RelativePath=".\lib\vauth\cleartext.c"/>
<File RelativePath=".\lib\vauth\vauth.c"/>
<File
RelativePath=".\lib\vauth\cleartext.c">
</File>
<File
RelativePath=".\lib\vauth\vauth.c">
</File>
</Filter>
</Filter>
<Filter
@@ -207,25 +357,51 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<Filter
Name="include">
<File RelativePath=".\include\curl\curl.h"/>
<File RelativePath=".\include\curl\curlver.h"/>
<File RelativePath=".\include\curl\easy.h"/>
<File RelativePath=".\include\curl\mprintf.h"/>
<File RelativePath=".\include\curl\multi.h"/>
<File RelativePath=".\include\curl\stdcheaders.h"/>
<File RelativePath=".\include\curl\system.h"/>
<File RelativePath=".\include\curl\typecheck-gcc.h"/>
<File RelativePath=".\include\curl\urlapi.h"/>
<File
RelativePath=".\include\curl\curl.h">
</File>
<File
RelativePath=".\include\curl\curlver.h">
</File>
<File
RelativePath=".\include\curl\easy.h">
</File>
<File
RelativePath=".\include\curl\mprintf.h">
</File>
<File
RelativePath=".\include\curl\multi.h">
</File>
<File
RelativePath=".\include\curl\stdcheaders.h">
</File>
<File
RelativePath=".\include\curl\system.h">
</File>
<File
RelativePath=".\include\curl\typecheck-gcc.h">
</File>
<File
RelativePath=".\include\curl\urlapi.h">
</File>
</Filter>
<Filter
Name="lib">
<File RelativePath=".\lib\curl_setup.h"/>
<File RelativePath=".\lib\urldata.h"/>
<File
RelativePath=".\lib\curl_setup.h">
</File>
<File
RelativePath=".\lib\urldata.h">
</File>
</Filter>
<Filter
Name="vtls">
<File RelativePath=".\lib\vtls\bearssl.h"/>
<File RelativePath=".\lib\vtls\vtls.h"/>
<File
RelativePath=".\lib\vtls\bearssl.h">
</File>
<File
RelativePath=".\lib\vtls\vtls.h">
</File>
</Filter>
</Filter>
</Files>