Fix: segfault in ETCP tests and add wintun.dll to gitignore
- Fix segfault in ETCP tests by initializing uECC RNG in sc_init_local_keys() - Fix segfault during cleanup by adding reference counting to socket_platform_cleanup() - Add wintun.dll to .gitignore - Update AGENTS.md and platform compatibility headers All 19 tests now pass successfully.
This commit is contained in:
1 parent
7781c4676b
commit
3ab19094d0
7 files changed
+38
-62
No files matched your search
@@ -68,3 +68,4 @@ utun.conf
|
||||
# MSVC temp files
|
||||
cl
|
||||
build_win.log
|
||||
wintun.dll
|
||||
@@ -194,14 +194,6 @@ sc_decrypt(&ctx, ciphertext, ciphertext_len, plaintext, &plaintext_len);
|
||||
2. **Undefined references:** Ensure source files are listed in Makefile.am
|
||||
3. **Link errors:** Check function declarations match definitions
|
||||
|
||||
### Testing Crypto
|
||||
```bash
|
||||
cd tests/
|
||||
./test_etcp_crypto # Should show all tests passing
|
||||
cd tests/
|
||||
./working_crypto_test # Standalone crypto test
|
||||
```
|
||||
|
||||
## 📦 Dependencies
|
||||
|
||||
### Build Dependencies
|
||||
@@ -233,7 +225,7 @@ Crypto: Fixed CCM nonce size to 13 bytes, all crypto tests passing
|
||||
1. Add new source file to `src/Makefile.am` under `utun_SOURCES`
|
||||
2. Add test file to `tests/Makefile.am` under `check_PROGRAMS`
|
||||
3. Use existing patterns from similar modules
|
||||
4. Run `make check` after changes
|
||||
4. Run `make check` after changes (win: build.bat and run_tests.bat)
|
||||
5. Commit with descriptive message in appropriate language
|
||||
|
||||
---
|
||||
@@ -295,4 +287,5 @@ Crypto: Fixed CCM nonce size to 13 bytes, all crypto tests passing
|
||||
стоп utun: sudo /home/vnc1/proj/utun3/utun_stop1.sh
|
||||
логи - utun.log
|
||||
|
||||
|
||||
*Last updated: 2026-02-13 - c_util fully functional with toc/description/show/edit commands*
|
||||
@@ -45,8 +45,10 @@
|
||||
#define _SSIZE_T_DEFINED
|
||||
#endif
|
||||
|
||||
// gettimeofday for Windows - provide our own implementation
|
||||
static inline int gettimeofday(struct timeval *tv, void *tz) {
|
||||
// gettimeofday for Windows - provide our own implementation if not already defined
|
||||
#ifndef _GETTIMEOFDAY_DEFINED
|
||||
#define _GETTIMEOFDAY_DEFINED
|
||||
static inline int utun_gettimeofday(struct timeval *tv, void *tz) {
|
||||
FILETIME ft;
|
||||
unsigned __int64 tmpres = 0;
|
||||
|
||||
@@ -67,6 +69,7 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // _GETTIMEOFDAY_DEFINED
|
||||
|
||||
// Pipe creation for Windows
|
||||
static inline int platform_pipe(int pipefd[2]) {
|
||||
|
||||
+21
-8
@@ -8,20 +8,33 @@
|
||||
#ifdef _WIN32
|
||||
// ==================== Windows Implementation ====================
|
||||
|
||||
static int wsa_init_count = 0;
|
||||
|
||||
int socket_platform_init(void) {
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (result != 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "WSAStartup failed: %d", result);
|
||||
return -1;
|
||||
if (wsa_init_count == 0) {
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (result != 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "WSAStartup failed: %d", result);
|
||||
return -1;
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "Winsock 2.2 initialized");
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "Winsock 2.2 initialized");
|
||||
wsa_init_count++;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "Winsock init count: %d", wsa_init_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void socket_platform_cleanup(void) {
|
||||
WSACleanup();
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "Winsock cleanup completed");
|
||||
if (wsa_init_count > 0) {
|
||||
wsa_init_count--;
|
||||
if (wsa_init_count == 0) {
|
||||
WSACleanup();
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "Winsock cleanup completed");
|
||||
} else {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "Winsock init count after cleanup: %d", wsa_init_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int socket_set_nonblocking(socket_t sock) {
|
||||
|
||||
@@ -574,6 +574,9 @@ sc_status_t sc_init_local_keys(struct SC_MYKEYS *mykeys, const char *public_key,
|
||||
curve = uECC_secp256r1();
|
||||
}
|
||||
|
||||
/* Set RNG function for TinyCrypt - must be done before any ECC operations */
|
||||
uECC_set_rng(sc_rng);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CRYPTO, "sc_init_local_keys: public_key len=%zu, private_key len=%zu",
|
||||
strlen(public_key), strlen(private_key));
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
[global]
|
||||
tun_ip=10.0.0.1
|
||||
mtu=1500 # MTU for all connections (0 = use default 1500)
|
||||
control_ip=127.0.0.1
|
||||
control_port=12345
|
||||
net_debug=0
|
||||
|
||||
my_node_id=61be9d4cd3c60c2d
|
||||
my_private_key=1313912e5d34768983b0e06530a48c77816d228a5b5605e1ab3dc443d107a3dc
|
||||
my_public_key=
|
||||
|
||||
|
||||
[routing]
|
||||
route_subnet=10.0.0.0/24
|
||||
route_subnet=10.22.0.0/16
|
||||
route_subnet=10.23.0.0/16
|
||||
my_subnet=10.23.5.0/24
|
||||
my_subnet=10.23.6.0/24
|
||||
|
||||
# мои адреса и каналы
|
||||
[server: lo0_test]
|
||||
addr=127.0.0.1:1330
|
||||
#so_mark=100
|
||||
#netif=eth0
|
||||
type=nat # public / nat / private
|
||||
|
||||
[server: lan1]
|
||||
addr=192.168.29.117:1333
|
||||
so_mark=100
|
||||
netif=eth0
|
||||
type=public # public / nat / private
|
||||
|
||||
[client: client_test1]
|
||||
|
||||
# линки
|
||||
link=lo0_test:192.168.0.20:1234
|
||||
#link=wired1_fast:1.2.3.4:1234
|
||||
link=lan1:192.168.0.20:1234
|
||||
#link=wireless_bkp:1.2.3.4:1234
|
||||
|
||||
keepalive=1
|
||||
peer_public_key=deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbee
|
||||
@@ -4,7 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include "test_utils.h"
|
||||
#include "../lib/platform_compat.h"
|
||||
#include "../src/etcp.h"
|
||||
|
||||
Reference in new issue
Block a user