update curl

This commit is contained in:
EqUiNoX
2026-02-16 14:09:10 -07:00
parent 319eb02364
commit a0f3eb7f45
15 changed files with 165 additions and 179 deletions
+6
View File
@@ -344,6 +344,9 @@
<File
RelativePath=".\ssl_debug.cpp">
</File>
<File
RelativePath=".\debug.cpp">
</File>
<File
RelativePath=".\session_cache.cpp">
</File>
@@ -1352,6 +1355,9 @@
<File
RelativePath=".\ssl_debug.h">
</File>
<File
RelativePath=".\ebug.h">
</File>
<File
RelativePath=".\session_cache.h">
</File>
+18 -18
View File
@@ -1,5 +1,4 @@
#include "ca_loader.h"
#include "debug_utility.h"
#include <xtl.h>
#include <winsockx.h>
@@ -9,6 +8,7 @@
#include <bearssl.h>
#include <bearssl_pem.h>
#include <bearssl_x509.h>
#include "debug.h"
#define DOWNLOAD_BUF_SIZE 8192
#define CA_DNS_TIMEOUT_MS 30000
@@ -324,7 +324,7 @@ int ca_loader::load_pem_file(const char *path,
FILE *f = fopen(path, "rb");
if (f == NULL)
{
debug_print("ca_loader: cannot open %s\n", path);
debug::print("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_print("ca_loader: file too large or empty (%ld bytes)\n", file_size);
debug::print("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_print("ca_loader: malloc failed for file data\n");
debug::print("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_print("ca_loader: short read (%u of %ld)\n",
debug::print("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_print("ca_loader: loaded %d trust anchors from %s (%d failed)\n",
debug::print("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_print("ca_loader: DNS failed for %s\n", host);
debug::print("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_print("ca_loader: connect failed to %s:%u\n",
debug::print("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_print("ca_loader: redirect %d -> %s%s\n",
debug::print("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_print("ca_loader: HTTP %d from %s%s\n",
debug::print("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_print("ca_loader: cannot create %s (err=%lu)\n",
debug::print("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_print("ca_loader: write error saving to %s\n",
debug::print("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_print("ca_loader: download too small (%I64d bytes)\n",
debug::print("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_print("ca_loader: rename %s -> %s failed\n",
debug::print("ca_loader: rename %s -> %s failed\n",
temp_path, save_path);
remove(temp_path);
return -1;
}
debug_print("ca_loader: downloaded %I64d bytes to %s\n",
debug::print("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_print("ca_loader: %s already exists, skipping download\n",
debug::print("ca_loader: %s already exists, skipping download\n",
save_path);
return 0;
}
if (anchors == NULL || anchor_count == 0)
{
debug_print("ca_loader: no trust anchors for download\n");
debug::print("ca_loader: no trust anchors for download\n");
return -1;
}
debug_print("ca_loader: downloading CA bundle from %s...\n",
debug::print("ca_loader: downloading CA bundle from %s...\n",
CA_BUNDLE_HOST);
return download_https(CA_BUNDLE_HOST, CA_BUNDLE_PATH, CA_BUNDLE_PORT,
+3 -3
View File
@@ -2,8 +2,6 @@
#include "ca_loader.h"
#include <bearssl_x509.h>
#include <xtl.h>
#include "debug_utility.h"
#include "trust_anchors.h"
#define NUM_TRUST_ANCHORS 750
@@ -24,7 +22,9 @@ void certificates::initialize_trust_anchors()
trust_anchors = (br_x509_trust_anchor*)malloc(NUM_TRUST_ANCHORS * sizeof br_x509_trust_anchor);
if (trust_anchors == NULL)
{
debug_print("certificates: FATAL - malloc failed for trust anchors!\n");
#ifdef _DEBUG
OutputDebugStringA("certificates: FATAL - malloc failed for trust anchors!\n");
#endif
return;
}
trust_anchor_count = NUM_TRUST_ANCHORS;
+25
View File
@@ -0,0 +1,25 @@
#include "debug.h"
#include <xtl.h>
#include <stdio.h>
#include <stdarg.h>
void debug::print(const char* format, ...)
{
#ifdef _DEBUG
va_list args;
va_start(args, format);
long length = _vsnprintf(NULL, 0, format, args);
char* message = (char*)malloc(length + 1);
_vsnprintf(message, length, format, args);
message[length] = 0;
va_end(args);
OutputDebugStringA(message);
free(message);
#else
(void)format;
#endif
}
+7
View File
@@ -0,0 +1,7 @@
#pragma once
class debug
{
public:
static void print(const char* format, ...);
};
-3
View File
@@ -1,3 +0,0 @@
#pragma once
void debug_print(const char* format, ...);
+3 -27
View File
@@ -131,27 +131,6 @@
<File
RelativePath=".\certificates.cpp">
</File>
<File
RelativePath=".\debug_utility.c">
<FileConfiguration
Name="Debug|Xbox">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Xbox">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release_LTCG|Xbox">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\session_cache.cpp">
</File>
@@ -161,6 +140,9 @@
<File
RelativePath=".\ssl_debug.cpp">
</File>
<File
RelativePath=".\debug.cpp">
</File>
<File
RelativePath=".\ssl_errors.cpp">
</File>
@@ -1123,12 +1105,6 @@
<File
RelativePath=".\libbearssl\inc\bearssl_x509.h">
</File>
<File
RelativePath=".\debug_utility.h">
</File>
<File
RelativePath=".\libbearssl\src\inner.h">
</File>
<File
RelativePath=".\missing\stdint.h">
</File>
@@ -2,7 +2,6 @@
#include <stddef.h>
#include <stdint.h>
#include "debug_utility.h"
typedef struct {
uint32_t *dp;
@@ -1288,7 +1287,11 @@ br_ssl_hs_client_run(void *t0ctx)
case 32: {
/* debug-session-ticket */
size_t len = T0_POP();
debug_print("BearSSL: NewSessionTicket received (%u bytes)\r\n", len);
#ifdef _DEBUG
char buffer[256];
sprintf(buffer, "BearSSL: NewSessionTicket received (%u bytes)\r\n", len);
OutputDebugStringA(buffer);
#endif
}
break;
case 33: {
+7 -7
View File
@@ -1,6 +1,6 @@
#include "ssl_debug.h"
#include "ssl_errors.h"
#include "debug_utility.h"
#include "debug.h"
#include <stdio.h>
#include <stdarg.h>
@@ -22,42 +22,42 @@ void ssl_debug::log_error(const char* format, ...)
{
if (current_level < SSL_DEBUG_ERROR) return;
debug_print("[SSL ERROR] ");
debug::print("[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_print("%s", buffer);
debug::print("%s", buffer);
}
void ssl_debug::log_info(const char* format, ...)
{
if (current_level < SSL_DEBUG_INFO) return;
debug_print("[SSL] ");
debug::print("[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_print("%s", buffer);
debug::print("%s", buffer);
}
void ssl_debug::log_verbose(const char* format, ...)
{
if (current_level < SSL_DEBUG_VERBOSE) return;
debug_print("[SSL DEBUG] ");
debug::print("[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_print("%s", buffer);
debug::print("%s", buffer);
}
const char* ssl_debug::version_to_string(unsigned version)
File diff suppressed because it is too large Load Diff
@@ -1,11 +1,9 @@
#include "debug_utility.h"
#include "debug.h"
#include <xtl.h>
#include <stdio.h>
#include <stdarg.h>
void debug_print(const char* format, ...)
void debug::print(const char* format, ...)
{
#ifdef _DEBUG
/* Use a fixed buffer since VS2003 doesn't support va_copy */
@@ -26,5 +24,7 @@ void debug_print(const char* format, ...)
}
OutputDebugStringA(message);
#else
(void)format;
#endif
}
}
+7
View File
@@ -0,0 +1,7 @@
#pragma once
class debug
{
public:
static void print(const char* format, ...);
};
-28
View File
@@ -1,28 +0,0 @@
#include "debug_utility.h"
#include <xtl.h>
#include <stdio.h>
#include <stdarg.h>
int debug_utility::debug_print(const char* format, ...)
{
/* Use a fixed buffer since VS2003 doesn't support va_copy */
char message[512];
va_list args;
int length;
va_start(args, format);
length = _vsnprintf(message, sizeof(message) - 1, format, args);
va_end(args);
/* Ensure null termination */
if (length < 0 || length >= (int)sizeof(message)) {
message[sizeof(message) - 1] = '\0';
length = (int)sizeof(message) - 1;
} else {
message[length] = '\0';
}
OutputDebugStringA(message);
return length;
}
-7
View File
@@ -1,7 +0,0 @@
#pragma once
class debug_utility
{
public:
static int debug_print(const char* format, ...);
};
+1 -1
View File
@@ -19,7 +19,7 @@
/* BearSSL debug support */
#include <bearssl.h>
#include "../BearSSL-OG/ssl_debug.h"
#include "../BearSSL-OG/debug_utility.h"
#include "../BearSSL-OG/debug.h"
#include "../BearSSL-OG/session_cache.h"
#include "../BearSSL-OG/cert_pinning.h"