mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-31 09:20:21 +00:00
scan-build fixes on win32 code paths
This commit is contained in:
parent
38f2a6b2c9
commit
5a32ccf220
@ -389,6 +389,7 @@ randombytes_salsa20_random_stir(void)
|
||||
CNGAPI_DRBG getrandom;
|
||||
HCRYPTPROV hProv;
|
||||
/* load bcrypt dynamically, see if we're already loaded */
|
||||
rtld = FALSE;
|
||||
hCAPINg = GetModuleHandle("bcrypt.dll");
|
||||
/* otherwise, load CNG manually */
|
||||
if (!hCAPINg)
|
||||
|
@ -4,6 +4,12 @@
|
||||
|
||||
#include <sodium/export.h>
|
||||
|
||||
// optimise the bit-flipping codepaths if we're on ix86
|
||||
#if defined(_WIN32) || defined(_M_IX86) || defined(_M_X64) \
|
||||
|| defined(__i386__) || defined(__amd64__)
|
||||
#define NATIVE_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
@ -1,8 +1,3 @@
|
||||
// saves us some calculation in the sodium bits
|
||||
#if defined(_WIN32) || defined(_M_IX86) || defined(_M_X64) \
|
||||
|| defined(__i386__) || defined(__amd64__)
|
||||
#define NATIVE_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <llarp/crypto.h>
|
||||
#include <sodium/crypto_generichash.h>
|
||||
|
@ -121,7 +121,7 @@ namespace llarp
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ssize_t
|
||||
do_write(void* data, size_t sz)
|
||||
{
|
||||
return WriteFile(std::get< HANDLE >(fd), data, sz, nullptr, tun_async[1]);
|
||||
|
@ -175,8 +175,10 @@ tdiGetIpAddrsForIpEntity(HANDLE tcpFile, TDIEntityID *ent, IPAddrEntry **addrs,
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "TdiGetIpAddrsForIpEntity(tcpFile 0x%p, entityId 0x%lx)\n",
|
||||
tcpFile, ent->tei_instance);
|
||||
#endif
|
||||
|
||||
status = tdiGetSetOfThings(tcpFile, INFO_CLASS_PROTOCOL, INFO_TYPE_PROVIDER,
|
||||
0x102, CL_NL_ENTITY, ent->tei_instance, 0,
|
||||
@ -448,6 +450,8 @@ getInterfaceIndexTableInt(BOOL nonLoopbackOnly)
|
||||
HANDLE tcpFile;
|
||||
NTSTATUS status = openTcpFile(&tcpFile, FILE_READ_DATA);
|
||||
|
||||
ifInfo = NULL;
|
||||
|
||||
if(NT_SUCCESS(status))
|
||||
{
|
||||
status = getInterfaceInfoSet(tcpFile, &ifInfo, &numInterfaces);
|
||||
|
22
vendor/libtuntap-master/tuntap-windows.c
vendored
22
vendor/libtuntap-master/tuntap-windows.c
vendored
@ -175,6 +175,10 @@ tuntap_start(struct device *dev, int mode, int tun)
|
||||
char *deviceid;
|
||||
char buf[60];
|
||||
|
||||
/* put something in there to avoid problems (uninitialised field access) */
|
||||
tun_fd = TUNFD_INVALID_VALUE;
|
||||
deviceid = NULL;
|
||||
|
||||
/* Don't re-initialise a previously started device */
|
||||
if(dev->tun_fd != TUNFD_INVALID_VALUE)
|
||||
{
|
||||
@ -198,6 +202,7 @@ tuntap_start(struct device *dev, int mode, int tun)
|
||||
else if(mode != TUNTAP_MODE_ETHERNET)
|
||||
{
|
||||
tuntap_log(TUNTAP_LOG_ERR, "Invalid parameter 'mode'");
|
||||
free(deviceid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -205,10 +210,12 @@ tuntap_start(struct device *dev, int mode, int tun)
|
||||
{
|
||||
int errcode = GetLastError();
|
||||
tuntap_log(TUNTAP_LOG_ERR, (const char *)formated_error(L"%1%0", errcode));
|
||||
free(deviceid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev->tun_fd = tun_fd;
|
||||
free(deviceid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -345,6 +352,13 @@ tuntap_sys_set_ipv4(struct device *dev, t_tun_in_addr *s, uint32_t mask)
|
||||
sock[1] = sock[0] & sock[2];
|
||||
ret = DeviceIoControl(dev->tun_fd, TAP_IOCTL_CONFIG_TUN, &sock, sizeof(sock),
|
||||
&sock, sizeof(sock), &len, NULL);
|
||||
if(!ret)
|
||||
{
|
||||
int errcode = GetLastError();
|
||||
tuntap_log(TUNTAP_LOG_ERR, (const char *)formated_error(L"%1%0", errcode));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ep[0] = s->S_un.S_addr;
|
||||
ep[1] = mask;
|
||||
ep[2] = (s->S_un.S_addr | ~mask)
|
||||
@ -355,6 +369,13 @@ tuntap_sys_set_ipv4(struct device *dev, t_tun_in_addr *s, uint32_t mask)
|
||||
ret = DeviceIoControl(dev->tun_fd, TAP_IOCTL_CONFIG_DHCP_MASQ, ep, sizeof(ep),
|
||||
ep, sizeof(ep), &len, NULL);
|
||||
|
||||
if(!ret)
|
||||
{
|
||||
int errcode = GetLastError();
|
||||
tuntap_log(TUNTAP_LOG_ERR, (const char *)formated_error(L"%1%0", errcode));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set DNS address to 127.0.0.1 as lokinet-client runs its own DNS resolver
|
||||
* inline */
|
||||
dns.dhcp_opt = 6;
|
||||
@ -370,7 +391,6 @@ tuntap_sys_set_ipv4(struct device *dev, t_tun_in_addr *s, uint32_t mask)
|
||||
if(!ret)
|
||||
{
|
||||
int errcode = GetLastError();
|
||||
|
||||
tuntap_log(TUNTAP_LOG_ERR, (const char *)formated_error(L"%1%0", errcode));
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user